/**
 * Created by Administrator on 2017/3/21.
 */
import React, {Component, Fragment} from 'react';
import {Form, Radio, Input, InputNumber, Icon as AIcon, Tabs, message, Button, Select, Modal, Upload} from 'antd';
import {connect} from 'dva';
import Map from 'ol/Map';
import View from 'ol/View';
import TileLayer from 'ol/layer/Tile';
import XYZ from 'ol/source/XYZ';
import {Vector} from 'ol/layer';
import request from '@/utils/request';
import config from '@/config/config'
import liuliangji from './../../images/liuliangji.png';
import gold_groud2 from './../../images/valve2.png';
import shuizhi from './../../images/shuizhi.png';
import dcjlq from './../../images/dcjlq.jpg';
import DN800SNLD from './../../images/DN800SNLD.jpg';
import DN800unknow from './../../images/DN800unknow.jpg';
import shuiweiji from './../../images/shuiweiji.png';
import DN300sf from './../../images/DN300sf.jpg';
import LDE from './../../images/LDE.jpg';
import temp11 from './../../images/temp11.png';
import temp12 from './../../images/temp12.png';
import temp26 from './../../images/temp26.png';
import temp13 from './../../images/temp13.jpg';
import temp14 from './../../images/temp14.jpg';
import temp24 from './../../images/temp24.jpg';
import temp25 from './../../images/temp25.jpg';
import temp21 from './../../images/temp21.jpg';
import styles from './index.less';
import find from 'lodash/find';
import {Vector as VectorSource} from 'ol/source';
import Feature from 'ol/Feature';
import {Icon, Stroke, Style} from 'ol/style';
import Point from 'ol/geom/Point';
import {fromLonLat, toLonLat} from 'ol/proj';

import yali from './../../images/location.png';
import Zmage from 'react-zmage';
import P0 from '../../images/valve.png';
import setting from './setting.json';
import axios from 'axios';
import GeoJSON from 'ol/format/GeoJSON';
import ControlValveConfig from './ControlValveConfig';
import BuildModalTitle from '@/components/BuildModalTitle';
import {afterCloseModal, download} from '@/utils/utils';
import moment from '../Meters/List';

const Option = Select.Option;
const FormItem = Form.Item;
const {TabPane} = Tabs;

class AddPoliciesForm extends Component {
  constructor(props) {
    super(props);

    this.state = {
      img: '',
      all_vendors: [],
      all_protocols: [],
      loading: false,
      layers: [
        new TileLayer({
          title: '天地图卫星影像',
          // visible: false,
          visible: true,
          source: new XYZ({
            crossOrigin: 'anonymous',
            url: 'https://tiles1.geovisearth.com/base/v1/img/{z}/{x}/{y}?format=webp&tmsIds=w&token=6dd3767b369eb5b724937e4ad74b2e78e95ad67ac7bbc1049539cb0691ad6ca2',//星图地球
          }),
        }),
        new TileLayer({
          title: '卫星标注',
          // visible: false,
          visible: true,
          source: new XYZ({
            crossOrigin: 'anonymous',
            url: 'https://tiles1.geovisearth.com/base/v1/cia/{z}/{x}/{y}?format=png&tmsIds=w&token=6dd3767b369eb5b724937e4ad74b2e78e95ad67ac7bbc1049539cb0691ad6ca2',//星图地球
          }),
        }),
        // new TileLayer({
        //   title: '天地图卫星影像',
        //   visible: true,
        //   source: new XYZ({
        //     crossOrigin: 'anonymous',
        //     url: 'http://t3.tianditu.com/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=136bb6f589f0402621a72ea362c9cb37',
        //   }),
        // }),
        // new TileLayer({
        //   title: '天地图路网',
        //   visible: false,
        //   source: new XYZ({
        //     url: 'http://t4.tianditu.com/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=136bb6f589f0402621a72ea362c9cb37',
        //   }),
        // }),
        // new TileLayer({
        //   title: '天地图文字标注',
        //   source: new XYZ({
        //     url: 'http://t3.tianditu.com/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=136bb6f589f0402621a72ea362c9cb37',
        //   }),
        // }),

      ],
      point: [],
      templateId: '',
      hardware_configs: {},
      config_index: 0,
      fileList: [],
    };
  }

  getMarker = () => {
    return this.state.point;
  };
  getConfig = () => {
    return {
      template: Number(this.state.templateId),
      hardware_configs: this.state.hardware_configs,
    };
  };

  componentDidMount() {
    const response = JSON.parse(JSON.stringify(setting));
    console.log('hd_response', response);
    if (!this.props.editRecord) {
      console.log('response', response);
      response.data.hardware_configs.modbus_03 = response.data.hardware_configs.modbus;
      response.data.hardware_configs.flowmeter = [{}, {}];
      this.setState({
        hardware_configs: response.data.hardware_configs,
      });
    } else {
      let editRecord = JSON.parse(JSON.stringify(this.props.editRecord));
      console.log('this.props.editRecord', editRecord);
      editRecord.hardware_configs.modbus_03 = editRecord.hardware_configs.modbus;
      if (editRecord.hardware_configs.device) {
        editRecord.hardware_configs.device[0].upload_interval = editRecord.hardware_configs.device[0].upload_interval / 60;
      }
      if (editRecord.template===40) {
        editRecord.hardware_configs.protobuf_json.rtu03.sensor_cfg.range = editRecord.hardware_configs.protobuf_json.rtu03.sensor_cfg.range / 1000;
        editRecord.hardware_configs.protobuf_json.rtu03.sensor_cfg.wave = editRecord.hardware_configs.protobuf_json.rtu03.sensor_cfg.wave / 1000;
      }
      this.setState({
        img: editRecord.cover_image_path,
        hardware_configs: editRecord.hardware_configs,
        templateId: editRecord.template.toString(),
      });
    }

    if (this.props.findChildFunc) {
      this.props.findChildFunc(this.getMarker);
    }

    if (this.props.getConfigFunc) {
      this.props.getConfigFunc(this.getConfig);
    }

    const that = this;
    if (this.props.fromPipeHome) {
      return false
    }
    let map = this.map = new Map({
      target: 'press_sensor_map',
      layers: this.state.layers,
      view: new View({
        center: this.props.editRecord ? fromLonLat([this.props.editRecord.longitude, this.props.editRecord.latitude]) : fromLonLat([89.176282, 42.948544]),//经纬度
        zoom: 14,
        maxZoom: 18,
        minZoom: 13,
      }),
    });
    let pointerLayer = null;
    if (this.props.editRecord) {
      console.log('this.props.editRecord', this.props.editRecord)
      this.setState({
        point: [this.props.editRecord.longitude, this.props.editRecord.latitude],
      }, function () {
        let mockvectorSource = that.createApoint(fromLonLat(this.state.point));
        // 创建标注图层
        pointerLayer = new Vector({
          source: mockvectorSource,
          zIndex: 12,

        });
        // 将标注图层添加到地图上
        map.addLayer(pointerLayer);
      });
    }
    map.on('click', function (e) {
      //在点击时获取像素区域;

      that.setState({
        point: toLonLat(e.coordinate),
      });
      if (pointerLayer) {
        map.removeLayer(pointerLayer);
      }
      let mockvectorSource = that.createApoint(e.coordinate);
      // 创建标注图层
      pointerLayer = new Vector({
        source: mockvectorSource,
        zIndex: 12,
      });
      // 将标注图层添加到地图上
      map.addLayer(pointerLayer);
    });

    axios(`https://test.zhsgy.top:37405/geoserver/tulufan/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=tulufan%3Anewpipeline&outputFormat=application%2Fjson`, {
      method: 'GET',
    })
      .then(response => {
        console.log('response', response);
        let designPipeVectorSource = this.designPipeVectorSource = new VectorSource({
          features: (new GeoJSON({featureProjection: 'EPSG:3857'})).readFeatures(response.data),
        });
        console.log('designPipeVectorSource', designPipeVectorSource);
        let designPipeVectorLayer = this.designPipeVectorLayer = new Vector({
          source: designPipeVectorSource,
          zIndex: 10,
          style: new Style({
            stroke: new Stroke({
              color: 'rgb(39,226,83)',
              width: 2,

            }),
          }),
        });
        this.map.addLayer(designPipeVectorLayer);
      });

  }

  createApoint = (coordinate) => {
    let point = new Feature({
      geometry: new Point(coordinate),
      name: '压力传感器',
    });
    //设置图标的样式
    point.setStyle(new Style({
      /**{olx.style.IconOptions}类型*/
      image: new Icon({
        anchorOrigin: 'top-right',
        offsetOrigin: 'top-right',
        src: yali,
      }),
    }));

    // 创建标注的数据源
    let mockvectorSource = new VectorSource({
      features: [point],
    });
    return mockvectorSource;
  };
  changeConfig = (newConfig) => {
    this.setState({
      hardware_configs: {...this.state.hardware_configs, ...newConfig},
    });
  };
  handleEditConfig = () => {
    const formValues = this.ConfigForm.props.form.getFieldsValue();
    console.log('formValues', formValues);
    if (!formValues.mode) {
      message.error('请先选择模式')
      return false
    }
    let itemsKey = []
    for (let i in formValues) {
      let splitKey = i.split('-')
      let len = splitKey.length;
      if (len >= 2) {
        if (itemsKey.indexOf(splitKey[1]) < 0) {
          itemsKey.push(splitKey[1])
        }
      }
    }
    console.log('itemsKey', itemsKey)
    const metersArr = []
    for (let i = 0; i < itemsKey.length; i++) {
      if (formValues[`time-${itemsKey[i]}`]) {
        metersArr.push({
          time: formValues[`time-${itemsKey[i]}`],
          pressure: formValues[`pressure-${itemsKey[i]}`],
        })
      }

    }
    console.log('metersArr', metersArr);
    let params = {
      upload_interval: formValues.upload_interval,
      high_error_pressure: formValues.high_error_pressure,
      low_error_pressure: formValues.low_error_pressure,
      mode: formValues.mode,
      device_number: this.state.device_number,
    }
    if (formValues.mode === 'manual') {
      params.target_pressure = formValues.target_pressure;
    } else if (formValues.mode === 'time_sharing') {
      params.time_sharing = metersArr;
    }
    const that = this;

    this.setState({
      loading: true,
    })

    request(`/workstations/${this.props.editRecord.id}/fj_config`, {
      method: 'PUT',
      data: params,
    }).then((response) => {
      if (response.status === 200) {
        message.success('调节阀配置成功')
        that.setState({
          configModal: false,
          loading: false,
        })
        that.props.saveConfig()
      }
    })

    setTimeout(function () {
      that.setState({
        loading: false
      })
    }, 30000)
  }

  render() {
    const formItemLayoutWithLabel = {
      labelCol: {
        xs: {span: 24},
        sm: {span: 4},
      },
      wrapperCol: {
        xs: {span: 24},
        sm: {span: 19},
      },
    };
    console.log(this.state.point);
    const that = this;
    let img = '';
    if (this.state.templateId === '1') {
      img = gold_groud2;
    } else if (this.state.templateId === '2') {
      img = liuliangji;
    } else if (this.state.templateId === '3') {
      img = shuizhi;
    } else if (this.state.templateId === '4') {
      img = dcjlq;
    } else if (this.state.templateId === '5') {
      img = DN800SNLD;
    } else if (this.state.templateId === '6') {
      img = DN800unknow;
    } else if (this.state.templateId === '7') {
      img = LDE;
    } else if (this.state.templateId === '8') {
      img = shuiweiji;
    } else if (this.state.templateId === '9') {
      img = gold_groud2;
    } else if (this.state.templateId === '10') {
      img = DN300sf;
    } else if (this.state.templateId === '11') {
      img = temp11;
    } else if (this.state.templateId === '12') {
      img = temp12;
    } else if (this.state.templateId === '13') {
      img = temp13;
    } else if (this.state.templateId === '14') {
      img = temp14;
    } else if (this.state.templateId === '21') {
      img = temp21;
    } else if (this.state.templateId === '24') {
      img = temp24;
    } else if (this.state.templateId === '25') {
      img = temp25;
    }  else if (this.state.templateId === '27') {
      img = temp25;
    } else if (this.state.templateId === '26') {
      img = temp26;
    } else if (this.state.templateId === '41') {
      img = shuizhi;
    }
    if (this.state.img) {
      img = this.state.img
    }
    const {getFieldDecorator} = this.props.form;
    const username = sessionStorage.getItem('username');
    const props = {
      onRemove: (file) => {
        this.setState(({fileList}) => {
          const index = fileList.indexOf(file);
          const newFileList = fileList.slice();
          newFileList.splice(index, 1);
          that.setState({
            img: ''
          })
          return {
            fileList: newFileList,
          };
        });
      },
      beforeUpload: (file) => {
        console.log(file)
        this.setState(({fileList}) => ({
          fileList: [file],
        }));

        const fd = new FormData()
        fd.append('file', file)
        fd.append('group', 'workstation')

        request(`/images`, {
          method: 'POST',
          data: fd
        }).then((response) => {
          console.log('images response', response)
          if (response.status === 200) {
            that.setState({
              img: response.data.data.path
            })
          }
        })
        return false;
      },
      fileList: this.state.fileList,
    };
    return (
      <div style={{marginBottom: '40px'}}>
        <Form onSubmit={this.handleSubmit}>
          <FormItem
            {...formItemLayoutWithLabel}
            label={(
              <span>
               站点名称
            </span>
            )}
          >
            {getFieldDecorator('name', {
              initialValue: this.props.editRecord ? this.props.editRecord.name : '',
              rules: [{required: true, message: '请输入名称'}],
            })(
              <Input/>,
            )}
          </FormItem>
          <FormItem
            {...formItemLayoutWithLabel}
            label={(
              <span>
               站点片区
            </span>
            )}
          >
            {getFieldDecorator('area', {
              initialValue: (this.props.editRecord && this.props.editRecord.hardware_configs && this.props.editRecord.hardware_configs.customize) ? this.props.editRecord.hardware_configs.customize.area : '',
            })(
              <Select onChange={(value) => {
                if (this.state.hardware_configs.customize.length === 0) {
                  this.state.hardware_configs.customize = {}
                }
                this.state.hardware_configs.customize.area = value;
                this.setState({
                  hardware_configs: this.state.hardware_configs,
                });
              }}>
                <Option value={'老城区'}>老城区</Option>
                <Option value={'港城区'}>港城区</Option>
                <Option value={'示范区'}>示范区</Option>
                <Option value={'塔尔郎水厂'}>塔尔郎水厂</Option>
                <Option value={'七泉湖水厂'}>七泉湖水厂</Option>
                <Option value={'示范区水厂'}>示范区水厂</Option>
                <Option value={'老城区水厂'}>老城区水厂</Option>
                <Option value={'园艺场沉砂池'}>园艺场沉砂池</Option>
                <Option value={'亚尔镇供水站'}>亚尔镇供水站</Option>
                <Option value={'艾丁湖供水站'}>艾丁湖供水站</Option>
                <Option value={'恰乡供水站'}>恰乡供水站</Option>
                <Option value={'火焰山供水站'}>火焰山供水站</Option>
                <Option value={'葡萄镇供水站'}>葡萄镇供水站</Option>
                <Option value={'胜金乡供水站'}>胜金乡供水站</Option>
                <Option value={'三堡乡供水站'}>三堡乡供水站</Option>
                <Option value={'污水井液位'}>污水井液位</Option>
              </Select>,
            )}
          </FormItem>
          <FormItem
            {...formItemLayoutWithLabel}
            label={(
              <span>
               站点地址
            </span>
            )}
          >
            {getFieldDecorator('address', {
              initialValue: this.props.editRecord ? this.props.editRecord.address : '',
            })(
              <Input/>,
            )}
          </FormItem>
          <FormItem
            {...formItemLayoutWithLabel}
            label={(
              <span>
               排序号
            </span>
            )}
            help={'排序号，0-9999，数字越小排序越前'}
          >
            {getFieldDecorator('sort', {
              initialValue: this.props.editRecord ? this.props.editRecord.sort : '9999',
              rules: [{required: true, message: '请输入名称'}],
            })(
              <Input/>,
            )}
          </FormItem>
          {
            !this.props.fromPipeHome &&
            <FormItem
              {...formItemLayoutWithLabel}
              label={(
                <span>
               地图
            </span>
              )}
            >
              <div id="press_sensor_map" style={{width: '100%', height: '350px'}}></div>
            </FormItem>
          }

        </Form>
        <FormItem
          {...formItemLayoutWithLabel}
          label={(
            <span>
             站点类型
          </span>
          )}>
          <Select style={{width: '100%'}} value={this.state.templateId}
                  disabled={!(username==='唐永臻'||Boolean(!this.props.editRecord))}
                  onChange={(e) => {
                    const response = JSON.parse(JSON.stringify(setting));
                    response.data.hardware_configs.modbus_03 = response.data.hardware_configs.modbus;
                    response.data.hardware_configs.flowmeter = [{}, {}];
                    this.setState({
                      templateId: e,
                      hardware_configs: response.data.hardware_configs,
                    }, function () {

                      if (e === '40') {
                        this.state.hardware_configs ={
                          customize: {},
                          "protobuf_json": { // RTU配置，除了通道号和Modbus上传间隔，其他写死
                            "rtu03": {
                              "cmd": "WRITE_PARAM",
                                "device_cfg": {
                                "state_interval": 3600,
                                  "record_interval": 60
                              },
                              "sensor_cfg": {
                                "type": "CURRENT",
                                  "range": 1.6,
                                  "wave": 0.05
                              },
                              "valve_cfg": {
                                "enable": true,
                                  "method_m1_param": {
                                    "p0": 0.0022,
                                    "p1": -0.6659,
                                    "p2": 71.093,
                                    "p3": 7576.8
                                }
                              },
                              "pms_cfg": {
                                "enable": false
                              },
                              "micro_motor_cfg": {
                                "enable": true,
                                  "delay": 60
                              }
                            }
                          }
                        }

                        this.setState({
                          hardware_configs: this.state.hardware_configs,
                        });
                      }else if (e === '1') {
                        this.state.hardware_configs.device[0].enable = 1;
                        this.state.hardware_configs.device[0].upload_interval = 60;
                        this.state.hardware_configs.flowmeter[0].enable = 0;
                        this.state.hardware_configs.flowmeter[1].enable = 0;
                        this.state.hardware_configs.customize.caliber = 1000;
                        this.state.hardware_configs.sensor[0].type = 'sensor001';
                        this.state.hardware_configs.sensor[0].alias = '阀前压力';
                        this.state.hardware_configs.sensor[0].normal_upload_interval = 900;
                        this.state.hardware_configs.sensor[0].alarm_upload_interval = 30;
                        this.state.hardware_configs.sensor[0].fluctuation_value = 0.05;
                        this.state.hardware_configs.sensor[0].alarm = 1;
                        this.state.hardware_configs.sensor[0].over = 0.8;
                        this.state.hardware_configs.sensor[0].over_cancel = 0.8;
                        this.state.hardware_configs.sensor[0].under = 0.3;
                        this.state.hardware_configs.sensor[0].under_cancel = 0.3;
                        this.state.hardware_configs.sensor[1].type = 'sensor001';
                        this.state.hardware_configs.sensor[1].alias = '阀后压力';
                        this.state.hardware_configs.sensor[1].normal_upload_interval = 900;
                        this.state.hardware_configs.sensor[1].alarm_upload_interval = 30;
                        this.state.hardware_configs.sensor[1].fluctuation_value = 0.05;
                        this.state.hardware_configs.sensor[1].alarm = 1;
                        this.state.hardware_configs.sensor[1].over = 0.7;
                        this.state.hardware_configs.sensor[1].over_cancel = 0.7;
                        this.state.hardware_configs.sensor[1].under = 0.3;
                        this.state.hardware_configs.sensor[1].under_cancel = 0.3;

                        this.state.hardware_configs.modbus_03[0].enable = 1;
                        this.state.hardware_configs.modbus_03[0].type = 'DOUBLE-VALVE-PLC';
                        this.state.hardware_configs.modbus_03[0].alias = '双阀';
                        this.state.hardware_configs.modbus_03[0].butterfly_valve1_status = 2;
                        this.state.hardware_configs.modbus_03[0].butterfly_valve2_status = 2;
                        this.state.hardware_configs.modbus_03[0].butterfly_valve3_status = 2;
                        this.state.hardware_configs.modbus_03[0].butterfly_valve4_status = 2;
                        this.state.hardware_configs.modbus_03[0].pressure_valve_pressure_limit_value = 0.6;
                        this.state.hardware_configs.control_valve[0].enable = '1';
                        this.state.hardware_configs.control_valve[0].alias = '调节阀';
                        this.state.hardware_configs.control_valve[0].device_number = '';

                        this.state.hardware_configs.digital_input[0].enable = '1';
                        this.state.hardware_configs.digital_input[0].alias = '液位传感器';
                        this.state.hardware_configs.digital_input[0].type = 'DigitalInput002';
                        this.state.hardware_configs.digital_input[0].alarm = 1;
                        this.state.hardware_configs.digital_input[0].normal_upload_interval = 600;
                        this.state.hardware_configs.digital_input[0].alarm_upload_interval = 30;
                        this.state.hardware_configs.digital_input[1].enable = 1;
                        this.state.hardware_configs.digital_input[1].alias = '井盖传感器';
                        this.state.hardware_configs.digital_input[1].type = 'DigitalInput003';
                        this.state.hardware_configs.digital_input[1].alarm = 1;
                        this.state.hardware_configs.digital_input[1].normal_upload_interval = 600;
                        this.state.hardware_configs.digital_input[1].alarm_upload_interval = 30;
                        this.setState({
                          hardware_configs: this.state.hardware_configs,
                        });
                      } else if (e === '9') {
                        this.state.hardware_configs.device[0].enable = 1;
                        this.state.hardware_configs.device[0].upload_interval = 60;
                        this.state.hardware_configs.customize.caliber = 1000;
                        this.state.hardware_configs.modbus_03[0].enable = 1;
                        this.state.hardware_configs.modbus_03[0].type = 'Modbus015_1';
                        this.state.hardware_configs.modbus_03[0].alias = '双阀';
                        this.state.hardware_configs.modbus_03[0].butterfly_valve1_status = 2;
                        this.state.hardware_configs.modbus_03[0].butterfly_valve2_status = 2;
                        this.state.hardware_configs.modbus_03[0].butterfly_valve3_status = 2;
                        this.state.hardware_configs.modbus_03[0].butterfly_valve4_status = 2;
                        this.state.hardware_configs.modbus_03[0].slave_address = 1;
                        this.state.hardware_configs.modbus_03[0].upload_interval = 900;
                        this.state.hardware_configs.modbus_03[1].type = 'Modbus015_2';
                        this.state.hardware_configs.modbus_03[1].alias = '压力';
                        this.state.hardware_configs.modbus_03[1].slave_address = 1;
                        this.state.hardware_configs.modbus_03[1].pressure_valve_pressure_limit_value = 0.6;
                        this.state.hardware_configs.modbus_03[1].upload_interval = 900;


                        this.state.hardware_configs.sensor[0].type = 'sensor002';
                        this.state.hardware_configs.sensor[0].alias = '液位';
                        this.state.hardware_configs.sensor[0].normal_upload_interval = 900;
                        this.state.hardware_configs.sensor[0].alarm_upload_interval = 30;
                        this.state.hardware_configs.sensor[0].fluctuation_value = 0;
                        this.state.hardware_configs.sensor[0].alarm = 1;
                        this.state.hardware_configs.sensor[0].over = 0.7;
                        this.state.hardware_configs.sensor[0].over_cancel = 0.7;
                        this.state.hardware_configs.sensor[0].under = 0.3;
                        this.state.hardware_configs.sensor[0].under_cancel = 0.3;

                        this.state.hardware_configs.digital_input[0].enable = 1;
                        this.state.hardware_configs.digital_input[0].alias = '井盖传感器';
                        this.state.hardware_configs.digital_input[0].type = 'DigitalInput003';
                        this.state.hardware_configs.digital_input[0].alarm = 1;
                        this.state.hardware_configs.digital_input[0].normal_upload_interval = 600;
                        this.state.hardware_configs.digital_input[0].alarm_upload_interval = 30;

                        this.setState({
                          hardware_configs: this.state.hardware_configs,
                        });
                      } else if (e === '2') {
                        this.state.hardware_configs.device[0].enable = 0;
                        this.state.hardware_configs.flowmeter[0].enable = 1;
                        this.state.hardware_configs.flowmeter[0].alias = '流量计';
                        this.state.hardware_configs.flowmeter[0].device_number = '';
                        this.state.hardware_configs.flowmeter[0].valve_status = 0;
                        this.state.hardware_configs.flowmeter[0].upload_interval = 12;
                        this.setState({
                          hardware_configs: this.state.hardware_configs,
                        });
                      } else if (e === '3') {
                        this.state.hardware_configs.flowmeter[0].enable = 0;
                        this.state.hardware_configs.flowmeter[1].enable = 0;

                        this.state.hardware_configs.device[0].enable = 1;
                        this.state.hardware_configs.device[0].upload_interval = 60;
                        this.state.hardware_configs.modbus_03[0].enable = 1;
                        this.state.hardware_configs.modbus_03[0].type = 'CHEMITEC-50-SERIES';
                        this.state.hardware_configs.modbus_03[0].alias = '水质监测';
                        this.state.hardware_configs.modbus_03[0].upload_interval = 900;
                        this.state.hardware_configs.modbus_03[0].channel1_type = 4;
                        this.state.hardware_configs.modbus_03[0].channel2_type = 3;
                        this.state.hardware_configs.modbus_03[0].channel3_type = 2;
                        this.state.hardware_configs.modbus_03[0].channel4_type = 1;

                        this.setState({
                          hardware_configs: this.state.hardware_configs,
                        });
                      } else if (e === '4') {
                        this.state.hardware_configs.flowmeter[0].enable = 0;
                        this.state.hardware_configs.flowmeter[1].enable = 0;

                        this.state.hardware_configs.device[0].enable = 1;
                        this.state.hardware_configs.device[0].upload_interval = 60;
                        this.state.hardware_configs.modbus_03[0].enable = 1;
                        this.state.hardware_configs.modbus_03[0].type = 'Modbus010';
                        this.state.hardware_configs.modbus_03[0].alias = '进水流量计';
                        this.state.hardware_configs.modbus_03[0].upload_interval = 900;
                        this.state.hardware_configs.modbus_03[0].slave_address = 1;
                        this.state.hardware_configs.modbus_03[0].min_instantaneous_flow = '-';
                        this.state.hardware_configs.modbus_03[0].max_instantaneous_flow = '-';

                        this.state.hardware_configs.modbus_03[1].type = 'Modbus010';
                        this.state.hardware_configs.modbus_03[1].alias = '出水流量计';
                        this.state.hardware_configs.modbus_03[1].upload_interval = 900;
                        this.state.hardware_configs.modbus_03[1].slave_address = 2;
                        this.state.hardware_configs.modbus_03[1].min_instantaneous_flow = '-';
                        this.state.hardware_configs.modbus_03[1].max_instantaneous_flow = '-';

                        this.setState({
                          hardware_configs: this.state.hardware_configs,
                        });
                      } else if (e === '5') {
                        this.state.hardware_configs.flowmeter[0].enable = 0;
                        this.state.hardware_configs.flowmeter[1].enable = 0;

                        this.state.hardware_configs.device[0].enable = 1;
                        this.state.hardware_configs.device[0].upload_interval = 60;
                        this.state.hardware_configs.modbus_03[0].enable = 1;
                        this.state.hardware_configs.modbus_03[0].type = 'Modbus012';
                        this.state.hardware_configs.modbus_03[0].alias = 'DN800电磁流量计';
                        this.state.hardware_configs.modbus_03[0].upload_interval = 900;
                        this.state.hardware_configs.modbus_03[0].slave_address = 1;
                        this.state.hardware_configs.modbus_03[0].min_instantaneous_flow = '-';
                        this.state.hardware_configs.modbus_03[0].max_instantaneous_flow = '-';

                        this.setState({
                          hardware_configs: this.state.hardware_configs,
                        });
                      } else if (e === '6') {
                        this.state.hardware_configs.flowmeter[0].enable = 0;
                        this.state.hardware_configs.flowmeter[1].enable = 0;

                        this.state.hardware_configs.device[0].enable = 1;
                        this.state.hardware_configs.device[0].upload_interval = 60;

                        this.state.hardware_configs.modbus_03[0].type = 'Modbus011';
                        this.state.hardware_configs.modbus_03[0].alias = 'DN800电磁流量计';
                        this.state.hardware_configs.modbus_03[0].upload_interval = 900;
                        this.state.hardware_configs.modbus_03[0].slave_address = 1;
                        this.state.hardware_configs.modbus_03[0].min_instantaneous_flow = '-';
                        this.state.hardware_configs.modbus_03[0].max_instantaneous_flow = '-';

                        this.setState({
                          hardware_configs: this.state.hardware_configs,
                        });
                      } else if (e === '7') {
                        this.state.hardware_configs.flowmeter[0].enable = 0;
                        this.state.hardware_configs.flowmeter[1].enable = 0;

                        this.state.hardware_configs.device[0].enable = 1;
                        this.state.hardware_configs.device[0].upload_interval = 60;
                        this.state.hardware_configs.modbus_03[0].enable = 1;
                        this.state.hardware_configs.modbus_03[0].type = 'Modbus013';
                        this.state.hardware_configs.modbus_03[0].alias = 'DN400电磁流量计';
                        this.state.hardware_configs.modbus_03[0].upload_interval = 900;
                        this.state.hardware_configs.modbus_03[0].slave_address = 1;
                        this.state.hardware_configs.modbus_03[0].min_instantaneous_flow = '-';
                        this.state.hardware_configs.modbus_03[0].max_instantaneous_flow = '-';

                        this.setState({
                          hardware_configs: this.state.hardware_configs,
                        });
                      } else if (e === '8') {
                        this.state.hardware_configs.flowmeter[0].enable = 0;
                        this.state.hardware_configs.flowmeter[1].enable = 0;

                        this.state.hardware_configs.device[0].enable = 1;
                        this.state.hardware_configs.device[0].upload_interval = 60;
                        this.state.hardware_configs.modbus_03[0].enable = 1;
                        this.state.hardware_configs.modbus_03[0].type = 'Modbus014_1';
                        this.state.hardware_configs.modbus_03[0].alias = '空高';
                        this.state.hardware_configs.modbus_03[0].upload_interval = 900;
                        this.state.hardware_configs.modbus_03[0].slave_address = 1;

                        this.state.hardware_configs.modbus_03[1].type = 'Modbus014_2';
                        this.state.hardware_configs.modbus_03[1].alias = '液位高';
                        this.state.hardware_configs.modbus_03[1].upload_interval = 900;
                        this.state.hardware_configs.modbus_03[1].slave_address = 1;

                        this.setState({
                          hardware_configs: this.state.hardware_configs,
                        });
                      } else if (e === '10') {
                        this.state.hardware_configs.flowmeter[0].enable = 0;
                        this.state.hardware_configs.flowmeter[1].enable = 0;
                        this.state.hardware_configs.customize.caliber = 1000;

                        this.state.hardware_configs.device[0].enable = 1;
                        this.state.hardware_configs.device[0].upload_interval = 60;

                        this.state.hardware_configs.modbus_03[0].type = 'Modbus016';
                        this.state.hardware_configs.modbus_03[0].alias = '宋峰电磁流量计';
                        this.state.hardware_configs.modbus_03[0].upload_interval = 900;
                        this.state.hardware_configs.modbus_03[0].slave_address = 1;
                        this.state.hardware_configs.modbus_03[0].min_instantaneous_flow = '-';
                        this.state.hardware_configs.modbus_03[0].max_instantaneous_flow = '-';

                        this.setState({
                          hardware_configs: this.state.hardware_configs,
                        });
                      } else if (e === '11') {
                        this.state.hardware_configs.flowmeter[0].enable = 0;
                        this.state.hardware_configs.flowmeter[1].enable = 0;

                        this.state.hardware_configs.device[0].enable = 1;
                        this.state.hardware_configs.device[0].upload_interval = 60;

                        this.state.hardware_configs.sensor[0].type = 'sensor001';
                        this.state.hardware_configs.sensor[0].alias = '压力计';
                        this.state.hardware_configs.sensor[0].normal_upload_interval = 900;
                        this.state.hardware_configs.sensor[0].alarm_upload_interval = 30;
                        this.state.hardware_configs.sensor[0].fluctuation_value = 0.05;
                        this.state.hardware_configs.sensor[0].alarm = 1;
                        this.state.hardware_configs.sensor[0].over = 0.8;
                        this.state.hardware_configs.sensor[0].over_cancel = 0.8;
                        this.state.hardware_configs.sensor[0].under = 0.3;
                        this.state.hardware_configs.sensor[0].under_cancel = 0.3;
                        this.state.hardware_configs.modbus_03[0].enable = 1;
                        this.state.hardware_configs.modbus_03[0].type = 'Modbus017';
                        this.state.hardware_configs.modbus_03[0].alias = '电磁流量计';
                        this.state.hardware_configs.modbus_03[0].upload_interval = 900;
                        this.state.hardware_configs.modbus_03[0].slave_address = 1;
                        this.state.hardware_configs.modbus_03[0].min_instantaneous_flow = '-';
                        this.state.hardware_configs.modbus_03[0].max_instantaneous_flow = '-';

                        this.setState({
                          hardware_configs: this.state.hardware_configs,
                        });
                      } else if (e === '12') {
                        this.state.hardware_configs.flowmeter[0].enable = 0;
                        this.state.hardware_configs.flowmeter[1].enable = 0;

                        this.state.hardware_configs.device[0].enable = 1;
                        this.state.hardware_configs.device[0].upload_interval = 60;

                        this.state.hardware_configs.sensor[0].type = 'sensor001';
                        this.state.hardware_configs.sensor[0].alias = '阀前压力';
                        this.state.hardware_configs.sensor[0].normal_upload_interval = 900;
                        this.state.hardware_configs.sensor[0].alarm_upload_interval = 30;
                        this.state.hardware_configs.sensor[0].fluctuation_value = 0.05;
                        this.state.hardware_configs.sensor[0].alarm = 1;
                        this.state.hardware_configs.sensor[0].over = 0.8;
                        this.state.hardware_configs.sensor[0].over_cancel = 0.8;
                        this.state.hardware_configs.sensor[0].under = 0.3;
                        this.state.hardware_configs.sensor[0].under_cancel = 0.3;
                        this.state.hardware_configs.sensor[1].type = 'sensor001';
                        this.state.hardware_configs.sensor[1].alias = '阀后压力';
                        this.state.hardware_configs.sensor[1].normal_upload_interval = 900;
                        this.state.hardware_configs.sensor[1].alarm_upload_interval = 30;
                        this.state.hardware_configs.sensor[1].fluctuation_value = 0.05;
                        this.state.hardware_configs.sensor[1].alarm = 1;
                        this.state.hardware_configs.sensor[1].over = 0.7;
                        this.state.hardware_configs.sensor[1].over_cancel = 0.7;
                        this.state.hardware_configs.sensor[1].under = 0.3;
                        this.state.hardware_configs.sensor[1].under_cancel = 0.3;

                        this.state.hardware_configs.modbus_03[0].enable = 1;
                        this.state.hardware_configs.modbus_03[0].type = 'Modbus018';
                        this.state.hardware_configs.modbus_03[0].alias = '液位探测器';
                        this.state.hardware_configs.modbus_03[0].slave_address = 2;
                        this.state.hardware_configs.modbus_03[0].alarm_water_level = 1;
                        this.state.hardware_configs.modbus_03[1].enable = 0;
                        this.state.hardware_configs.modbus_03[1].type = '';

                        this.state.hardware_configs.digital_input[0].enable = 1;
                        this.state.hardware_configs.digital_input[0].alias = '井盖传感器';
                        this.state.hardware_configs.digital_input[0].type = 'DigitalInput003';
                        this.state.hardware_configs.digital_input[0].alarm = 1;
                        this.state.hardware_configs.digital_input[0].normal_upload_interval = 600;
                        this.state.hardware_configs.digital_input[0].alarm_upload_interval = 30;

                        this.setState({
                          hardware_configs: this.state.hardware_configs,
                        });
                      } else if (e === '26') {
                        this.state.hardware_configs.flowmeter[0].enable = 0;
                        this.state.hardware_configs.flowmeter[1].enable = 0;

                        this.state.hardware_configs.device[0].enable = 1;
                        this.state.hardware_configs.device[0].upload_interval = 60;

                        this.state.hardware_configs.sensor[0].type = 'sensor001';
                        this.state.hardware_configs.sensor[0].alias = '阀前压力';
                        this.state.hardware_configs.sensor[0].normal_upload_interval = 900;
                        this.state.hardware_configs.sensor[0].alarm_upload_interval = 30;
                        this.state.hardware_configs.sensor[0].fluctuation_value = 0.05;
                        this.state.hardware_configs.sensor[0].alarm = 1;
                        this.state.hardware_configs.sensor[0].over = 0.8;
                        this.state.hardware_configs.sensor[0].over_cancel = 0.8;
                        this.state.hardware_configs.sensor[0].under = 0.3;
                        this.state.hardware_configs.sensor[0].under_cancel = 0.3;
                        this.state.hardware_configs.sensor[1].type = 'sensor001';
                        this.state.hardware_configs.sensor[1].alias = '阀后压力';
                        this.state.hardware_configs.sensor[1].normal_upload_interval = 900;
                        this.state.hardware_configs.sensor[1].alarm_upload_interval = 30;
                        this.state.hardware_configs.sensor[1].fluctuation_value = 0.05;
                        this.state.hardware_configs.sensor[1].alarm = 1;
                        this.state.hardware_configs.sensor[1].over = 0.7;
                        this.state.hardware_configs.sensor[1].over_cancel = 0.7;
                        this.state.hardware_configs.sensor[1].under = 0.3;
                        this.state.hardware_configs.sensor[1].under_cancel = 0.3;

                        this.state.hardware_configs.modbus_03[0].enable = 1;
                        this.state.hardware_configs.modbus_03[0].type = 'Modbus018';
                        this.state.hardware_configs.modbus_03[0].alias = '液位探测器';
                        this.state.hardware_configs.modbus_03[0].slave_address = 2;
                        this.state.hardware_configs.modbus_03[0].alarm_water_level = 1;
                        this.state.hardware_configs.modbus_03[1].enable = 0;
                        this.state.hardware_configs.modbus_03[1].type = '';
                        this.state.hardware_configs.modbus_03[1].alias = '空';
                        this.state.hardware_configs.modbus_03[2].enable = 0;
                        this.state.hardware_configs.modbus_03[2].type = '';
                        this.state.hardware_configs.modbus_03[2].alias = '空';
                        this.state.hardware_configs.modbus_03[3].enable = 0;
                        this.state.hardware_configs.modbus_03[3].type = '';
                        this.state.hardware_configs.modbus_03[3].alias = '空';

                        this.state.hardware_configs.control_valve[0].enable = '1';
                        this.state.hardware_configs.control_valve[0].alias = '调节阀';
                        this.state.hardware_configs.control_valve[0].device_number = '';

                        this.state.hardware_configs.digital_input[0].enable = 1;
                        this.state.hardware_configs.digital_input[0].alias = '井盖传感器';
                        this.state.hardware_configs.digital_input[0].type = 'DigitalInput003';
                        this.state.hardware_configs.digital_input[0].alarm = 1;
                        this.state.hardware_configs.digital_input[0].normal_upload_interval = 600;
                        this.state.hardware_configs.digital_input[0].alarm_upload_interval = 30;

                        this.setState({
                          hardware_configs: this.state.hardware_configs,
                        });
                      } else if (e === '35') {
                        this.state.hardware_configs.flowmeter[0].enable = 0;
                        this.state.hardware_configs.flowmeter[1].enable = 0;

                        this.state.hardware_configs.device[0].enable = 1;
                        this.state.hardware_configs.device[0].upload_interval = 60;

                        this.state.hardware_configs.sensor[0].type = 'sensor001';
                        this.state.hardware_configs.sensor[0].alias = '阀前压力';
                        this.state.hardware_configs.sensor[0].normal_upload_interval = 900;
                        this.state.hardware_configs.sensor[0].alarm_upload_interval = 30;
                        this.state.hardware_configs.sensor[0].fluctuation_value = 0.05;
                        this.state.hardware_configs.sensor[0].alarm = 1;
                        this.state.hardware_configs.sensor[0].over = 0.8;
                        this.state.hardware_configs.sensor[0].over_cancel = 0.8;
                        this.state.hardware_configs.sensor[0].under = 0.3;
                        this.state.hardware_configs.sensor[0].under_cancel = 0.3;
                        this.state.hardware_configs.sensor[1].type = 'sensor001';
                        this.state.hardware_configs.sensor[1].alias = '阀后压力';
                        this.state.hardware_configs.sensor[1].normal_upload_interval = 900;
                        this.state.hardware_configs.sensor[1].alarm_upload_interval = 30;
                        this.state.hardware_configs.sensor[1].fluctuation_value = 0.05;
                        this.state.hardware_configs.sensor[1].alarm = 1;
                        this.state.hardware_configs.sensor[1].over = 0.7;
                        this.state.hardware_configs.sensor[1].over_cancel = 0.7;
                        this.state.hardware_configs.sensor[1].under = 0.3;
                        this.state.hardware_configs.sensor[1].under_cancel = 0.3;

                        this.state.hardware_configs.modbus_03[0].enable = 1;
                        this.state.hardware_configs.modbus_03[0].type = 'Modbus024';
                        this.state.hardware_configs.modbus_03[0].alias = '双阀';
                        this.state.hardware_configs.modbus_03[0].butterfly_valve1_status = 2;
                        this.state.hardware_configs.modbus_03[0].butterfly_valve2_status = 2;
                        this.state.hardware_configs.modbus_03[0].butterfly_valve3_status = 2;
                        this.state.hardware_configs.modbus_03[0].butterfly_valve4_status = 2;
                        this.state.hardware_configs.modbus_03[0].slave_address = 1;
                        this.state.hardware_configs.modbus_03[0].upload_interval = 900;
                        this.state.hardware_configs.modbus_03[1].enable = 0;
                        this.state.hardware_configs.modbus_03[1].type = '';
                        this.state.hardware_configs.modbus_03[1].alias = '空';
                        this.state.hardware_configs.modbus_03[2].enable = 0;
                        this.state.hardware_configs.modbus_03[2].type = '';
                        this.state.hardware_configs.modbus_03[2].alias = '空';

                        this.state.hardware_configs.modbus_03[3].enable = 1;
                        this.state.hardware_configs.modbus_03[3].type = 'Modbus018';
                        this.state.hardware_configs.modbus_03[3].alias = '液位探测器';
                        this.state.hardware_configs.modbus_03[3].slave_address = 2;
                        this.state.hardware_configs.modbus_03[3].alarm_water_level = 1;


                        this.state.hardware_configs.digital_input[0].enable = 1;
                        this.state.hardware_configs.digital_input[0].alias = '井盖传感器';
                        this.state.hardware_configs.digital_input[0].type = 'DigitalInput003';
                        this.state.hardware_configs.digital_input[0].alarm = 1;
                        this.state.hardware_configs.digital_input[0].normal_upload_interval = 600;
                        this.state.hardware_configs.digital_input[0].alarm_upload_interval = 30;

                        this.setState({
                          hardware_configs: this.state.hardware_configs,
                        });
                      }  else if (e === '36') {
                        this.state.hardware_configs.flowmeter[0].enable = 0;
                        this.state.hardware_configs.flowmeter[1].enable = 0;

                        this.state.hardware_configs.device[0].enable = 1;
                        this.state.hardware_configs.device[0].upload_interval = 60;

                        this.state.hardware_configs.sensor[0].type = 'sensor001';
                        this.state.hardware_configs.sensor[0].alias = '阀前压力';
                        this.state.hardware_configs.sensor[0].normal_upload_interval = 900;
                        this.state.hardware_configs.sensor[0].alarm_upload_interval = 30;
                        this.state.hardware_configs.sensor[0].fluctuation_value = 0.05;
                        this.state.hardware_configs.sensor[0].alarm = 1;
                        this.state.hardware_configs.sensor[0].over = 0.8;
                        this.state.hardware_configs.sensor[0].over_cancel = 0.8;
                        this.state.hardware_configs.sensor[0].under = 0.3;
                        this.state.hardware_configs.sensor[0].under_cancel = 0.3;
                        this.state.hardware_configs.sensor[1].type = 'sensor001';
                        this.state.hardware_configs.sensor[1].alias = '阀后压力';
                        this.state.hardware_configs.sensor[1].normal_upload_interval = 900;
                        this.state.hardware_configs.sensor[1].alarm_upload_interval = 30;
                        this.state.hardware_configs.sensor[1].fluctuation_value = 0.05;
                        this.state.hardware_configs.sensor[1].alarm = 1;
                        this.state.hardware_configs.sensor[1].over = 0.7;
                        this.state.hardware_configs.sensor[1].over_cancel = 0.7;
                        this.state.hardware_configs.sensor[1].under = 0.3;
                        this.state.hardware_configs.sensor[1].under_cancel = 0.3;

                        this.state.hardware_configs.modbus_03[0].enable = 1;
                        this.state.hardware_configs.modbus_03[0].type = 'Modbus024';
                        this.state.hardware_configs.modbus_03[0].alias = '双阀';
                        this.state.hardware_configs.modbus_03[0].butterfly_valve1_status = 2;
                        this.state.hardware_configs.modbus_03[0].butterfly_valve2_status = 2;
                        this.state.hardware_configs.modbus_03[0].butterfly_valve3_status = 2;
                        this.state.hardware_configs.modbus_03[0].butterfly_valve4_status = 2;
                        this.state.hardware_configs.modbus_03[0].slave_address = 1;
                        this.state.hardware_configs.modbus_03[0].upload_interval = 900;
                        this.state.hardware_configs.modbus_03[2].enable = 0;
                        this.state.hardware_configs.modbus_03[2].type = '';
                        this.state.hardware_configs.modbus_03[2].alias = '空';
                        this.state.hardware_configs.modbus_03[3].enable = 0;
                        this.state.hardware_configs.modbus_03[3].type = '';
                        this.state.hardware_configs.modbus_03[3].alias = '空';

                        this.state.hardware_configs.modbus_03[1].enable = 1;
                        this.state.hardware_configs.modbus_03[1].type = 'Modbus018';
                        this.state.hardware_configs.modbus_03[1].alias = '液位探测器';
                        this.state.hardware_configs.modbus_03[1].slave_address = 2;
                        this.state.hardware_configs.modbus_03[1].alarm_water_level = 1;

                        this.state.hardware_configs.control_valve[0].enable = '1';
                        this.state.hardware_configs.control_valve[0].alias = '调节阀';
                        this.state.hardware_configs.control_valve[0].device_number = '';

                        this.state.hardware_configs.digital_input[0].enable = 1;
                        this.state.hardware_configs.digital_input[0].alias = '井盖传感器';
                        this.state.hardware_configs.digital_input[0].type = 'DigitalInput003';
                        this.state.hardware_configs.digital_input[0].alarm = 1;
                        this.state.hardware_configs.digital_input[0].normal_upload_interval = 600;
                        this.state.hardware_configs.digital_input[0].alarm_upload_interval = 30;

                        this.setState({
                          hardware_configs: this.state.hardware_configs,
                        });
                      } else if (e === '23') {
                        this.state.hardware_configs.flowmeter[0].enable = 0;
                        this.state.hardware_configs.flowmeter[1].enable = 0;

                        this.state.hardware_configs.device[0].enable = 1;
                        this.state.hardware_configs.device[0].upload_interval = 60;

                        this.state.hardware_configs.sensor[0].type = 'sensor001';
                        this.state.hardware_configs.sensor[0].alias = '阀前压力';
                        this.state.hardware_configs.sensor[0].normal_upload_interval = 900;
                        this.state.hardware_configs.sensor[0].alarm_upload_interval = 30;
                        this.state.hardware_configs.sensor[0].fluctuation_value = 0.05;
                        this.state.hardware_configs.sensor[0].alarm = 1;
                        this.state.hardware_configs.sensor[0].over = 0.8;
                        this.state.hardware_configs.sensor[0].over_cancel = 0.8;
                        this.state.hardware_configs.sensor[0].under = 0.3;
                        this.state.hardware_configs.sensor[0].under_cancel = 0.3;
                        this.state.hardware_configs.sensor[1].type = 'sensor001';
                        this.state.hardware_configs.sensor[1].alias = '阀后压力';
                        this.state.hardware_configs.sensor[1].normal_upload_interval = 900;
                        this.state.hardware_configs.sensor[1].alarm_upload_interval = 30;
                        this.state.hardware_configs.sensor[1].fluctuation_value = 0.05;
                        this.state.hardware_configs.sensor[1].alarm = 1;
                        this.state.hardware_configs.sensor[1].over = 0.7;
                        this.state.hardware_configs.sensor[1].over_cancel = 0.7;
                        this.state.hardware_configs.sensor[1].under = 0.3;
                        this.state.hardware_configs.sensor[1].under_cancel = 0.3;

                        this.state.hardware_configs.sensor[2].type = 'sensor002';
                        this.state.hardware_configs.sensor[2].alias = '液位';
                        this.state.hardware_configs.sensor[2].normal_upload_interval = 900;
                        this.state.hardware_configs.sensor[2].alarm_upload_interval = 30;
                        this.state.hardware_configs.sensor[2].fluctuation_value = 0;
                        this.state.hardware_configs.sensor[2].alarm = 0;
                        this.state.hardware_configs.sensor[2].over = 0.7;
                        this.state.hardware_configs.sensor[2].over_cancel = 0.7;
                        this.state.hardware_configs.sensor[2].under = 0.3;
                        this.state.hardware_configs.sensor[2].under_cancel = 0.3;

                        this.state.hardware_configs.digital_input[0].enable = 1;
                        this.state.hardware_configs.digital_input[0].alias = '井盖传感器';
                        this.state.hardware_configs.digital_input[0].type = 'DigitalInput003';
                        this.state.hardware_configs.digital_input[0].alarm = 1;
                        this.state.hardware_configs.digital_input[0].normal_upload_interval = 600;
                        this.state.hardware_configs.digital_input[0].alarm_upload_interval = 30;

                        this.setState({
                          hardware_configs: this.state.hardware_configs,
                        });
                      } else if (e === '22') {
                        this.state.hardware_configs.flowmeter[0].enable = 0;
                        this.state.hardware_configs.flowmeter[1].enable = 0;

                        this.state.hardware_configs.device[0].enable = 1;
                        this.state.hardware_configs.device[0].upload_interval = 60;

                        this.state.hardware_configs.sensor[0].type = 'sensor002';
                        this.state.hardware_configs.sensor[0].alias = '液位传感器1';
                        this.state.hardware_configs.sensor[0].normal_upload_interval = 900;
                        this.state.hardware_configs.sensor[0].alarm_upload_interval = 30;
                        this.state.hardware_configs.sensor[0].fluctuation_value = 0.05;
                        this.state.hardware_configs.sensor[0].alarm = 1;
                        this.state.hardware_configs.sensor[0].over = 0.8;
                        this.state.hardware_configs.sensor[0].over_cancel = 0.8;
                        this.state.hardware_configs.sensor[0].under = 0.3;
                        this.state.hardware_configs.sensor[0].under_cancel = 0.3;
                        this.state.hardware_configs.sensor[1].type = 'sensor002';
                        this.state.hardware_configs.sensor[1].alias = '液位传感器2';
                        this.state.hardware_configs.sensor[1].normal_upload_interval = 900;
                        this.state.hardware_configs.sensor[1].alarm_upload_interval = 30;
                        this.state.hardware_configs.sensor[1].fluctuation_value = 0.05;
                        this.state.hardware_configs.sensor[1].alarm = 1;
                        this.state.hardware_configs.sensor[1].over = 0.7;
                        this.state.hardware_configs.sensor[1].over_cancel = 0.7;
                        this.state.hardware_configs.sensor[1].under = 0.3;
                        this.state.hardware_configs.sensor[1].under_cancel = 0.3;

                        this.state.hardware_configs.modbus_03[0].enable = 1;
                        this.state.hardware_configs.modbus_03[0].type = 'Modbus018';
                        this.state.hardware_configs.modbus_03[0].alias = '液位探测器';
                        this.state.hardware_configs.modbus_03[0].slave_address = 2;
                        this.state.hardware_configs.modbus_03[0].alarm_water_level = 1;
                        this.state.hardware_configs.modbus_03[1].enable = 0;
                        this.state.hardware_configs.modbus_03[1].type = '';
                        this.state.hardware_configs.modbus_03[1].alias = '空';

                        this.setState({
                          hardware_configs: this.state.hardware_configs,
                        });
                      } else if (e === '19') {
                        this.state.hardware_configs.flowmeter[0].enable = 0;
                        this.state.hardware_configs.flowmeter[1].enable = 0;

                        this.state.hardware_configs.device[0].enable = 1;
                        this.state.hardware_configs.device[0].upload_interval = 60;

                        this.state.hardware_configs.sensor[0].type = 'sensor001';
                        this.state.hardware_configs.sensor[0].alias = '阀前压力';
                        this.state.hardware_configs.sensor[0].normal_upload_interval = 900;
                        this.state.hardware_configs.sensor[0].alarm_upload_interval = 30;
                        this.state.hardware_configs.sensor[0].fluctuation_value = 0.05;
                        this.state.hardware_configs.sensor[0].alarm = 1;
                        this.state.hardware_configs.sensor[0].over = 0.8;
                        this.state.hardware_configs.sensor[0].over_cancel = 0.8;
                        this.state.hardware_configs.sensor[0].under = 0.3;
                        this.state.hardware_configs.sensor[0].under_cancel = 0.3;
                        this.state.hardware_configs.sensor[1].type = 'sensor001';
                        this.state.hardware_configs.sensor[1].alias = '阀后压力';
                        this.state.hardware_configs.sensor[1].normal_upload_interval = 900;
                        this.state.hardware_configs.sensor[1].alarm_upload_interval = 30;
                        this.state.hardware_configs.sensor[1].fluctuation_value = 0.05;
                        this.state.hardware_configs.sensor[1].alarm = 1;
                        this.state.hardware_configs.sensor[1].over = 0.7;
                        this.state.hardware_configs.sensor[1].over_cancel = 0.7;
                        this.state.hardware_configs.sensor[1].under = 0.3;
                        this.state.hardware_configs.sensor[1].under_cancel = 0.3;

                        this.state.hardware_configs.modbus_03[3].enable = 1; //原来是channel0
                        this.state.hardware_configs.modbus_03[3].type = 'Modbus018';
                        this.state.hardware_configs.modbus_03[3].alias = '液位探测器';
                        this.state.hardware_configs.modbus_03[3].slave_address = 2;
                        this.state.hardware_configs.modbus_03[3].alarm_water_level = 1;

                        this.state.hardware_configs.modbus_03[0].enable = 1;
                        this.state.hardware_configs.modbus_03[0].type = 'Modbus023';
                        this.state.hardware_configs.modbus_03[0].alias = '双阀调流阀';
                        this.state.hardware_configs.modbus_03[0].control_mode = 0;
                        this.state.hardware_configs.modbus_03[0].slave_address = 1;
                        this.state.hardware_configs.modbus_03[0].target_pressure_value = 0;
                        this.state.hardware_configs.modbus_03[0].target_opening_value = 0;
                        this.state.hardware_configs.modbus_03[0].butterfly_valve1_status = 2;
                        this.state.hardware_configs.modbus_03[0].butterfly_valve2_status = 2;
                        this.state.hardware_configs.modbus_03[0].butterfly_valve3_status = 2;
                        this.state.hardware_configs.modbus_03[0].butterfly_valve4_status = 2;
                        this.state.hardware_configs.modbus_03[0].upload_interval = 900;

                        this.state.hardware_configs.digital_input[0].enable = 1;
                        this.state.hardware_configs.digital_input[0].alias = '井盖传感器';
                        this.state.hardware_configs.digital_input[0].type = 'DigitalInput003';
                        this.state.hardware_configs.digital_input[0].alarm = 1;
                        this.state.hardware_configs.digital_input[0].normal_upload_interval = 600;
                        this.state.hardware_configs.digital_input[0].alarm_upload_interval = 30;


                        this.setState({
                          hardware_configs: this.state.hardware_configs,
                        });
                      } else if (e === '29') {
                        this.state.hardware_configs.flowmeter[0].enable = 0;
                        this.state.hardware_configs.flowmeter[1].enable = 0;

                        this.state.hardware_configs.device[0].enable = 1;
                        this.state.hardware_configs.device[0].upload_interval = 60;

                        this.state.hardware_configs.sensor[0].type = 'sensor001';
                        this.state.hardware_configs.sensor[0].alias = '阀前压力';
                        this.state.hardware_configs.sensor[0].normal_upload_interval = 900;
                        this.state.hardware_configs.sensor[0].alarm_upload_interval = 30;
                        this.state.hardware_configs.sensor[0].fluctuation_value = 0.05;
                        this.state.hardware_configs.sensor[0].alarm = 1;
                        this.state.hardware_configs.sensor[0].over = 0.8;
                        this.state.hardware_configs.sensor[0].over_cancel = 0.8;
                        this.state.hardware_configs.sensor[0].under = 0.3;
                        this.state.hardware_configs.sensor[0].under_cancel = 0.3;
                        this.state.hardware_configs.sensor[1].type = 'sensor001';
                        this.state.hardware_configs.sensor[1].alias = '阀后压力';
                        this.state.hardware_configs.sensor[1].normal_upload_interval = 900;
                        this.state.hardware_configs.sensor[1].alarm_upload_interval = 30;
                        this.state.hardware_configs.sensor[1].fluctuation_value = 0.05;
                        this.state.hardware_configs.sensor[1].alarm = 1;
                        this.state.hardware_configs.sensor[1].over = 0.7;
                        this.state.hardware_configs.sensor[1].over_cancel = 0.7;
                        this.state.hardware_configs.sensor[1].under = 0.3;
                        this.state.hardware_configs.sensor[1].under_cancel = 0.3;

                        this.state.hardware_configs.modbus_03[0].enable = 1;
                        this.state.hardware_configs.modbus_03[0].type = 'Modbus018';
                        this.state.hardware_configs.modbus_03[0].alias = '液位探测器';
                        this.state.hardware_configs.modbus_03[0].slave_address = 2;
                        this.state.hardware_configs.modbus_03[0].alarm_water_level = 1;
                        this.state.hardware_configs.modbus_03[1].enable = 1;
                        this.state.hardware_configs.modbus_03[1].type = 'Modbus020';
                        this.state.hardware_configs.modbus_03[1].alias = '调流阀';
                        this.state.hardware_configs.modbus_03[1].slave_address = 1;
                        this.state.hardware_configs.modbus_03[1].target_pressure_value = '';
                        this.state.hardware_configs.modbus_03[2].type = 'Modbus015_1';
                        this.state.hardware_configs.modbus_03[2].alias = '双阀';
                        this.state.hardware_configs.modbus_03[2].butterfly_valve1_status = 2;
                        this.state.hardware_configs.modbus_03[2].butterfly_valve2_status = 2;
                        this.state.hardware_configs.modbus_03[2].butterfly_valve3_status = 2;
                        this.state.hardware_configs.modbus_03[2].butterfly_valve4_status = 2;
                        this.state.hardware_configs.modbus_03[2].slave_address = 3;
                        this.state.hardware_configs.modbus_03[2].upload_interval = 900;
                        this.state.hardware_configs.modbus_03[3].enable = 0;
                        this.state.hardware_configs.modbus_03[3].type = '';
                        this.state.hardware_configs.modbus_03[3].alias = '空';

                        this.setState({
                          hardware_configs: this.state.hardware_configs,
                        });
                      } else if (e === '13') {
                        this.state.hardware_configs.device[0].enable = 1;
                        this.state.hardware_configs.device[0].upload_interval = 60;
                        this.state.hardware_configs.flowmeter[0].enable = 0;
                        this.state.hardware_configs.flowmeter[1].enable = 0;
                        this.state.hardware_configs.customize.caliber = 1000;
                        this.state.hardware_configs.sensor[0].type = 'sensor001';
                        this.state.hardware_configs.sensor[0].alias = '阀前压力';
                        this.state.hardware_configs.sensor[0].normal_upload_interval = 900;
                        this.state.hardware_configs.sensor[0].alarm_upload_interval = 30;
                        this.state.hardware_configs.sensor[0].fluctuation_value = 0.05;
                        this.state.hardware_configs.sensor[0].alarm = 1;
                        this.state.hardware_configs.sensor[0].over = 0.8;
                        this.state.hardware_configs.sensor[0].over_cancel = 0.8;
                        this.state.hardware_configs.sensor[0].under = 0.3;
                        this.state.hardware_configs.sensor[0].under_cancel = 0.3;
                        this.state.hardware_configs.sensor[1].type = 'sensor001';
                        this.state.hardware_configs.sensor[1].alias = '阀后压力';
                        this.state.hardware_configs.sensor[1].normal_upload_interval = 900;
                        this.state.hardware_configs.sensor[1].alarm_upload_interval = 30;
                        this.state.hardware_configs.sensor[1].fluctuation_value = 0.05;
                        this.state.hardware_configs.sensor[1].alarm = 1;
                        this.state.hardware_configs.sensor[1].over = 0.7;
                        this.state.hardware_configs.sensor[1].over_cancel = 0.7;
                        this.state.hardware_configs.sensor[1].under = 0.3;
                        this.state.hardware_configs.sensor[1].under_cancel = 0.3;
                        this.state.hardware_configs.modbus_03[0].enable = 1;
                        this.state.hardware_configs.modbus_03[0].type = 'DOUBLE-VALVE-PLC';
                        this.state.hardware_configs.modbus_03[0].alias = '双阀';
                        this.state.hardware_configs.modbus_03[0].butterfly_valve1_status = 2;
                        this.state.hardware_configs.modbus_03[0].butterfly_valve2_status = 2;
                        this.state.hardware_configs.modbus_03[0].butterfly_valve3_status = 2;
                        this.state.hardware_configs.modbus_03[0].butterfly_valve4_status = 2;
                        this.state.hardware_configs.modbus_03[0].pressure_valve_pressure_limit_value = 0.6;
                        this.state.hardware_configs.modbus_03[0].slave_address = 1;
                        this.state.hardware_configs.modbus_03[1].enable = 1;
                        this.state.hardware_configs.modbus_03[1].type = 'Modbus018';
                        this.state.hardware_configs.modbus_03[1].alias = '液位探测器';
                        this.state.hardware_configs.modbus_03[1].slave_address = 2;
                        this.state.hardware_configs.modbus_03[1].alarm_water_level = 1;

                        this.state.hardware_configs.digital_input[0].enable = '1';
                        this.state.hardware_configs.digital_input[0].alias = '液位传感器';
                        this.state.hardware_configs.digital_input[0].type = 'DigitalInput002';
                        this.state.hardware_configs.digital_input[0].alarm = 1;
                        this.state.hardware_configs.digital_input[0].normal_upload_interval = 600;
                        this.state.hardware_configs.digital_input[0].alarm_upload_interval = 30;
                        this.state.hardware_configs.digital_input[1].enable = '1';
                        this.state.hardware_configs.digital_input[1].alias = '井盖传感器';
                        this.state.hardware_configs.digital_input[1].type = 'DigitalInput003';
                        this.state.hardware_configs.digital_input[1].alarm = 1;
                        this.state.hardware_configs.digital_input[1].normal_upload_interval = 600;
                        this.state.hardware_configs.digital_input[1].alarm_upload_interval = 30;
                        this.setState({
                          hardware_configs: this.state.hardware_configs,
                        });
                      } else if (e === '15') {
                        this.state.hardware_configs.flowmeter[0].enable = 0;
                        this.state.hardware_configs.flowmeter[1].enable = 0;

                        this.state.hardware_configs.device[0].enable = 1;
                        this.state.hardware_configs.device[0].upload_interval = 60;
                        this.state.hardware_configs.modbus_03[0].enable = 1;
                        this.state.hardware_configs.modbus_03[0].type = 'Modbus019';
                        this.state.hardware_configs.modbus_03[0].alias = '老城区水厂-出水流量';
                        this.state.hardware_configs.modbus_03[0].upload_interval = 900;
                        this.state.hardware_configs.modbus_03[0].slave_address = 1;
                        this.state.hardware_configs.modbus_03[0].min_instantaneous_flow = '-';
                        this.state.hardware_configs.modbus_03[0].max_instantaneous_flow = '-';

                        this.setState({
                          hardware_configs: this.state.hardware_configs,
                        });
                      } else if (e === '16' || e === '18') {
                        this.state.hardware_configs.flowmeter[0].enable = 0;
                        this.state.hardware_configs.flowmeter[1].enable = 0;

                        this.state.hardware_configs.device[0].enable = 1;
                        this.state.hardware_configs.device[0].upload_interval = 60;

                        this.state.hardware_configs.sensor[0].type = 'sensor002';
                        this.state.hardware_configs.sensor[1].type = '';
                        this.state.hardware_configs.sensor[0].alias = '液位传感器';
                        this.state.hardware_configs.sensor[0].normal_upload_interval = 900;
                        this.state.hardware_configs.sensor[0].alarm_upload_interval = 900;
                        this.state.hardware_configs.sensor[0].fluctuation_value = 0;
                        this.state.hardware_configs.sensor[0].alarm = 0;
                        this.state.hardware_configs.sensor[0].over = 0.8;
                        this.state.hardware_configs.sensor[0].over_cancel = 0.8;
                        this.state.hardware_configs.sensor[0].under = 0.3;
                        this.state.hardware_configs.sensor[0].under_cancel = 0.3;

                        this.setState({
                          hardware_configs: this.state.hardware_configs,
                        });
                      } else if (e === '17') {
                        this.state.hardware_configs.flowmeter[0].enable = 0;
                        this.state.hardware_configs.flowmeter[1].enable = 0;

                        this.state.hardware_configs.device[0].enable = 1;
                        this.state.hardware_configs.device[0].upload_interval = 60;

                        this.state.hardware_configs.sensor[0].type = 'sensor002';//量程3.8
                        this.state.hardware_configs.sensor[1].type = '';
                        this.state.hardware_configs.sensor[0].alias = '液位传感器';
                        this.state.hardware_configs.sensor[0].normal_upload_interval = 900;
                        this.state.hardware_configs.sensor[0].alarm_upload_interval = 900;
                        this.state.hardware_configs.sensor[0].fluctuation_value = 0;
                        this.state.hardware_configs.sensor[0].alarm = 0;
                        this.state.hardware_configs.sensor[0].over = 0.8;
                        this.state.hardware_configs.sensor[0].over_cancel = 0.8;
                        this.state.hardware_configs.sensor[0].under = 0.3;
                        this.state.hardware_configs.sensor[0].under_cancel = 0.3;

                        this.setState({
                          hardware_configs: this.state.hardware_configs,
                        });
                      } else if (e === '20') {
                        this.state.hardware_configs.flowmeter[0].enable = 0;
                        this.state.hardware_configs.flowmeter[1].enable = 0;

                        this.state.hardware_configs.device[0].enable = 1;
                        this.state.hardware_configs.device[0].upload_interval = 60;

                        this.state.hardware_configs.sensor[0].enable = 0;
                        this.state.hardware_configs.sensor[0].type = '';
                        this.state.hardware_configs.sensor[0].alias = '液位传感器';
                        this.state.hardware_configs.sensor[0].normal_upload_interval = 900;
                        this.state.hardware_configs.sensor[0].alarm_upload_interval = 900;
                        this.state.hardware_configs.sensor[0].fluctuation_value = 0;
                        this.state.hardware_configs.sensor[0].alarm = 0;
                        this.state.hardware_configs.sensor[0].over = 0.8;
                        this.state.hardware_configs.sensor[0].over_cancel = 0.8;
                        this.state.hardware_configs.sensor[0].under = 0.3;
                        this.state.hardware_configs.sensor[0].under_cancel = 0.3;

                        this.state.hardware_configs.sensor[1].enable = 1;
                        this.state.hardware_configs.sensor[1].type = 'sensor002';
                        this.state.hardware_configs.sensor[1].alias = '液位传感器';
                        this.state.hardware_configs.sensor[1].normal_upload_interval = 900;
                        this.state.hardware_configs.sensor[1].alarm_upload_interval = 900;
                        this.state.hardware_configs.sensor[1].fluctuation_value = 0
                        this.state.hardware_configs.sensor[1].alarm = 0;
                        this.state.hardware_configs.sensor[1].over = 0.8;
                        this.state.hardware_configs.sensor[1].over_cancel = 0.8;
                        this.state.hardware_configs.sensor[1].under = 0.3;
                        this.state.hardware_configs.sensor[1].under_cancel = 0.3;

                        this.state.hardware_configs.sensor[2].enable = 0;
                        this.state.hardware_configs.sensor[2].type = '';

                        this.state.hardware_configs.sensor[3].enable = 0;
                        this.state.hardware_configs.sensor[3].type = '';


                        this.setState({
                          hardware_configs: this.state.hardware_configs,
                        });
                      } else if (e === '14') {
                        this.state.hardware_configs.flowmeter[0].enable = 0;
                        this.state.hardware_configs.flowmeter[1].enable = 0;

                        this.state.hardware_configs.device[0].enable = 1;
                        this.state.hardware_configs.device[0].upload_interval = 60;
                        this.state.hardware_configs.modbus_03[0].enable = 1;
                        this.state.hardware_configs.modbus_03[0].type = 'CHEMITEC-50-SERIES';
                        this.state.hardware_configs.modbus_03[0].alias = '水质监测';
                        this.state.hardware_configs.modbus_03[0].upload_interval = 900;
                        this.state.hardware_configs.modbus_03[0].channel1_type = 4;
                        this.state.hardware_configs.modbus_03[0].channel2_type = 3;
                        this.state.hardware_configs.modbus_03[0].channel3_type = 2;
                        this.state.hardware_configs.modbus_03[0].channel4_type = 1;

                        this.state.hardware_configs.sensor[0].type = 'sensor002';
                        this.state.hardware_configs.sensor[0].alias = '液位传感器';
                        this.state.hardware_configs.sensor[0].normal_upload_interval = 900;
                        this.state.hardware_configs.sensor[0].alarm_upload_interval = 900;
                        this.state.hardware_configs.sensor[0].fluctuation_value = 0;
                        this.state.hardware_configs.sensor[0].alarm = 0;
                        this.state.hardware_configs.sensor[0].over = 0.8;
                        this.state.hardware_configs.sensor[0].over_cancel = 0.8;
                        this.state.hardware_configs.sensor[0].under = 0.3;
                        this.state.hardware_configs.sensor[0].under_cancel = 0.3;

                        this.setState({
                          hardware_configs: this.state.hardware_configs,
                        });
                      } else if (e === '21') {
                        this.state.hardware_configs.flowmeter[0].enable = 0;
                        this.state.hardware_configs.flowmeter[1].enable = 0;

                        this.state.hardware_configs.device[0].enable = 1;
                        this.state.hardware_configs.device[0].upload_interval = 60;

                        this.state.hardware_configs.sensor[0].type = 'sensor001';
                        this.state.hardware_configs.sensor[0].alias = '阀后压力';
                        this.state.hardware_configs.sensor[0].normal_upload_interval = 900;
                        this.state.hardware_configs.sensor[0].alarm_upload_interval = 30;
                        this.state.hardware_configs.sensor[0].fluctuation_value = 0.05;
                        this.state.hardware_configs.sensor[0].alarm = 1;
                        this.state.hardware_configs.sensor[0].over = 0.4;
                        this.state.hardware_configs.sensor[0].over_cancel = 0.4;
                        this.state.hardware_configs.sensor[0].under = 0.3;
                        this.state.hardware_configs.sensor[0].under_cancel = 0.3;

                        this.state.hardware_configs.ball_valve[0].enable = 1;
                        this.state.hardware_configs.ball_valve[0].mode = 2;
                        this.state.hardware_configs.ball_valve[0].parameter1 = 0;
                        this.state.hardware_configs.ball_valve[0].parameter2 = 0;
                        this.state.hardware_configs.ball_valve[0].parameter3 = 0;
                        this.state.hardware_configs.ball_valve[0].parameter4 = 1;

                        this.state.hardware_configs.ball_valve[1].enable = 1;
                        this.state.hardware_configs.ball_valve[1].mode = 2;
                        this.state.hardware_configs.ball_valve[1].parameter1 = 0;
                        this.state.hardware_configs.ball_valve[1].parameter2 = 1;
                        this.state.hardware_configs.ball_valve[1].parameter3 = 0;
                        this.state.hardware_configs.ball_valve[1].parameter4 = 0;

                        this.setState({
                          hardware_configs: this.state.hardware_configs,
                        });
                      } else if (e === '24') {
                        this.state.hardware_configs.flowmeter[0].enable = 0;
                        this.state.hardware_configs.flowmeter[1].enable = 0;

                        this.state.hardware_configs.device[0].enable = 0;
                        this.state.hardware_configs.modbus_03[0].enable = 0;

                        this.setState({
                          hardware_configs: this.state.hardware_configs,
                        });
                      }else if (e === '41') {
                        this.state.hardware_configs.flowmeter[0].enable = 0;
                        this.state.hardware_configs.flowmeter[1].enable = 0;

                        this.state.hardware_configs.device[0].enable = 0;
                        this.state.hardware_configs.modbus_03[0].enable = 0;

                        this.setState({
                          hardware_configs: this.state.hardware_configs,
                        });
                      } else if (e === '42') {
                        this.state.hardware_configs.flowmeter[0].enable = 0;
                        this.state.hardware_configs.flowmeter[1].enable = 0;

                        this.state.hardware_configs.device[0].enable = 0;
                        this.state.hardware_configs.modbus_03[0].enable = 0;

                        this.setState({
                          hardware_configs: this.state.hardware_configs,
                        });
                      } else if (e === '43'||e === '44'||e === '45') {
                        this.state.hardware_configs.flowmeter[0].enable = 0;
                        this.state.hardware_configs.flowmeter[1].enable = 0;

                        this.state.hardware_configs.device[0].enable = 0;
                        this.state.hardware_configs.modbus_03[0].enable = 0;

                        this.setState({
                          hardware_configs: this.state.hardware_configs,
                        });
                      } else if (e === '25') {
                        this.state.hardware_configs.flowmeter[0].enable = 0;
                        this.state.hardware_configs.flowmeter[1].enable = 0;

                        this.state.hardware_configs.device[0].enable = 1;
                        this.state.hardware_configs.device[0].upload_interval = 60;

                        this.state.hardware_configs.sensor[0].type = 'sensor001';
                        this.state.hardware_configs.sensor[0].alias = '阀前压力';
                        this.state.hardware_configs.sensor[0].normal_upload_interval = 900;
                        this.state.hardware_configs.sensor[0].alarm_upload_interval = 30;
                        this.state.hardware_configs.sensor[0].fluctuation_value = 0.05;
                        this.state.hardware_configs.sensor[0].alarm = 1;
                        this.state.hardware_configs.sensor[0].over = 0.4;
                        this.state.hardware_configs.sensor[0].over_cancel = 0.4;
                        this.state.hardware_configs.sensor[0].under = 0.3;
                        this.state.hardware_configs.sensor[0].under_cancel = 0.3;

                        this.state.hardware_configs.sensor[1].type = 'sensor001';
                        this.state.hardware_configs.sensor[1].alias = '阀后压力';
                        this.state.hardware_configs.sensor[1].normal_upload_interval = 900;
                        this.state.hardware_configs.sensor[1].alarm_upload_interval = 30;
                        this.state.hardware_configs.sensor[1].fluctuation_value = 0.05;
                        this.state.hardware_configs.sensor[1].alarm = 1;
                        this.state.hardware_configs.sensor[1].over = 0.4;
                        this.state.hardware_configs.sensor[1].over_cancel = 0.4;
                        this.state.hardware_configs.sensor[1].under = 0.3;
                        this.state.hardware_configs.sensor[1].under_cancel = 0.3;

                        this.state.hardware_configs.sensor[2].type = 'sensor002';
                        this.state.hardware_configs.sensor[2].alias = '液位';
                        this.state.hardware_configs.sensor[2].normal_upload_interval = 900;
                        this.state.hardware_configs.sensor[2].alarm_upload_interval = 30;
                        this.state.hardware_configs.sensor[2].fluctuation_value = 0;
                        this.state.hardware_configs.sensor[2].alarm = 1;
                        this.state.hardware_configs.sensor[2].over = 0.7;
                        this.state.hardware_configs.sensor[2].over_cancel = 0.7;
                        this.state.hardware_configs.sensor[2].under = 0.3;
                        this.state.hardware_configs.sensor[2].under_cancel = 0.3;

                        this.state.hardware_configs.ball_valve[0].enable = 1;
                        this.state.hardware_configs.ball_valve[0].mode = 2;
                        this.state.hardware_configs.ball_valve[0].parameter1 = 1;
                        this.state.hardware_configs.ball_valve[0].parameter2 = 0;
                        this.state.hardware_configs.ball_valve[0].parameter3 = 0;
                        this.state.hardware_configs.ball_valve[0].parameter4 = 1;

                        this.state.hardware_configs.ball_valve[1].enable = 1;
                        this.state.hardware_configs.ball_valve[1].mode = 2;
                        this.state.hardware_configs.ball_valve[1].parameter1 = 1;
                        this.state.hardware_configs.ball_valve[1].parameter2 = 1;
                        this.state.hardware_configs.ball_valve[1].parameter3 = 0;
                        this.state.hardware_configs.ball_valve[1].parameter4 = 0;

                        this.state.hardware_configs.digital_input[0].enable = 1;
                        this.state.hardware_configs.digital_input[0].alias = '井盖传感器';
                        this.state.hardware_configs.digital_input[0].type = 'DigitalInput003';
                        this.state.hardware_configs.digital_input[0].alarm = 1;
                        this.state.hardware_configs.digital_input[0].normal_upload_interval = 600;
                        this.state.hardware_configs.digital_input[0].alarm_upload_interval = 30;


                        this.setState({
                          hardware_configs: this.state.hardware_configs,
                        });
                      }else if (e === '27') {
                        this.state.hardware_configs.flowmeter[0].enable = 0;
                        this.state.hardware_configs.flowmeter[1].enable = 0;

                        this.state.hardware_configs.device[0].enable = 1;
                        this.state.hardware_configs.device[0].upload_interval = 60;

                        this.state.hardware_configs.sensor[0].type = 'sensor001';
                        this.state.hardware_configs.sensor[0].alias = '阀前压力';
                        this.state.hardware_configs.sensor[0].normal_upload_interval = 900;
                        this.state.hardware_configs.sensor[0].alarm_upload_interval = 30;
                        this.state.hardware_configs.sensor[0].fluctuation_value = 0.05;
                        this.state.hardware_configs.sensor[0].alarm = 1;
                        this.state.hardware_configs.sensor[0].over = 0.4;
                        this.state.hardware_configs.sensor[0].over_cancel = 0.4;
                        this.state.hardware_configs.sensor[0].under = 0.3;
                        this.state.hardware_configs.sensor[0].under_cancel = 0.3;

                        this.state.hardware_configs.sensor[1].type = 'sensor001';
                        this.state.hardware_configs.sensor[1].alias = '阀后压力';
                        this.state.hardware_configs.sensor[1].normal_upload_interval = 900;
                        this.state.hardware_configs.sensor[1].alarm_upload_interval = 30;
                        this.state.hardware_configs.sensor[1].fluctuation_value = 0.05;
                        this.state.hardware_configs.sensor[1].alarm = 1;
                        this.state.hardware_configs.sensor[1].over = 0.4;
                        this.state.hardware_configs.sensor[1].over_cancel = 0.4;
                        this.state.hardware_configs.sensor[1].under = 0.3;
                        this.state.hardware_configs.sensor[1].under_cancel = 0.3;

                        this.state.hardware_configs.sensor[2].type = 'sensor002';
                        this.state.hardware_configs.sensor[2].alias = '液位';
                        this.state.hardware_configs.sensor[2].normal_upload_interval = 900;
                        this.state.hardware_configs.sensor[2].alarm_upload_interval = 30;
                        this.state.hardware_configs.sensor[2].fluctuation_value = 0;
                        this.state.hardware_configs.sensor[2].alarm = 1;
                        this.state.hardware_configs.sensor[2].over = 0.7;
                        this.state.hardware_configs.sensor[2].over_cancel = 0.7;
                        this.state.hardware_configs.sensor[2].under = 0.3;
                        this.state.hardware_configs.sensor[2].under_cancel = 0.3;


                        this.state.hardware_configs.digital_input[0].enable = 1;
                        this.state.hardware_configs.digital_input[0].alias = '井盖传感器';
                        this.state.hardware_configs.digital_input[0].type = 'DigitalInput003';
                        this.state.hardware_configs.digital_input[0].alarm = 1;
                        this.state.hardware_configs.digital_input[0].normal_upload_interval = 600;
                        this.state.hardware_configs.digital_input[0].alarm_upload_interval = 30;


                        this.setState({
                          hardware_configs: this.state.hardware_configs,
                        });
                      }
                    });
                  }}>
            {/* <Option value={'1'}>双蝶阀站点</Option> */}
            <Option value={'9'}>双阀减压阀站点</Option>
            {/* <Option value={'2'}>流量计站点</Option> */}
            <Option value={'3'}>水质监测站点</Option>
            <Option value={'41'}>水质监测站点(WH采集器)</Option>
            <Option value={'44'}>液位监测站点(WH采集器)</Option>
            <Option value={'4'}>电磁计量器站点</Option>
            <Option value={'5'}>DN800电磁流量计(SNLD-DN800)</Option>
            <Option value={'6'}>DN800电磁流量计(待定)</Option>
            {/* <Option value={'7'}>LDE-DN400-400(珠华)</Option> */}
            {/* <Option value={'8'}>JEER雷达水位计</Option> */}
            <Option value={'10'}>宋峰流量计</Option>
            <Option value={'11'}>电磁流量计&压力计</Option>
            <Option value={'42'}>流量液位站点(MK采集器)</Option>
            <Option value={'43'}>流量站点(MK采集器)</Option>
            <Option value={'45'}>液位站点(MK采集器)</Option>
            <Option value={'12'}>双压力监测点</Option>
            <Option value={'26'}>双压力监测点(RLB)</Option>
            <Option value={'19'}>双压力监测点(双阀调流阀)</Option>
            <Option value={'35'}>双压力监测点(新双阀调流阀)</Option>
            <Option value={'36'}>双压力监测点(新双阀调流阀RLB)</Option>
            {/*<Option value={'29'}>双压力双阀监测点(带调流阀)</Option>*/}
            {/* <Option value={'22'}>双压力监测点(量程0~8米)</Option> */}
            <Option value={'23'}>双压力液位监测点</Option>
            {/* <Option value={'13'}>阀井液位站点</Option> */}
           {/* <Option value={'15'}>老城区水厂-出水流量</Option>*/}
            <Option value={'16'}>单液位站点-通道1</Option>
            {/*      <Option value={'17'}>老城区水厂-2#液位</Option>
            <Option value={'18'}>示范区水厂-液位</Option> */}
            {/*<Option value={'14'}>园艺场沉砂池-水质液位</Option>
            <Option value={'20'}>单液位站点-通道2</Option>*/}
            {/*<Option value={'21'}>单压力监测点(带球阀)</Option>*/}
            <Option value={'24'}>流量压力监测点(WH采集器)</Option>
            <Option value={'25'}>减压阀控制站点(带球阀)</Option>
            <Option value={'27'}>减压阀控制站点</Option>{/*少两个球阀*/}
            <Option value={'40'}>减压阀远程控制站点</Option>


          </Select>
        </FormItem>


        {
          Boolean(Number(this.state.templateId)) &&
          <Fragment>
            <FormItem
              {...formItemLayoutWithLabel}
              label={(
                <span>
               站点图片
            </span>
              )}>

              <Zmage src={img} alt="" style={{width: 300}}/>
              <div style={{width: '300px'}}>

                {getFieldDecorator('file', {})(
                  <Upload.Dragger {...props}>
                    <p className="ant-upload-text" style={{fontSize: '14px'}}><AIcon type="inbox"/>更改图片</p>
                  </Upload.Dragger>
                )}
              </div>
            </FormItem>
            {
              (Number(this.state.templateId) === 1 || Number(this.state.templateId) === 3 || Number(this.state.templateId) === 4
                || Number(this.state.templateId) === 5 || Number(this.state.templateId) === 6 || Number(this.state.templateId) === 7
                || Number(this.state.templateId) === 8 || Number(this.state.templateId) === 9 || Number(this.state.templateId) === 10
                || Number(this.state.templateId) === 11 || Number(this.state.templateId) === 12 || Number(this.state.templateId) === 13
                || Number(this.state.templateId) === 14 || Number(this.state.templateId) === 15 || Number(this.state.templateId) === 16
                || Number(this.state.templateId) === 17 || Number(this.state.templateId) === 18 || Number(this.state.templateId) === 19
                || Number(this.state.templateId) === 20 || Number(this.state.templateId) === 21 || Number(this.state.templateId) === 22
                || Number(this.state.templateId) === 23 || Number(this.state.templateId) === 24 || Number(this.state.templateId) === 25|| Number(this.state.templateId) === 27
                || Number(this.state.templateId) === 26 || Number(this.state.templateId) === 35 ||Number(this.state.templateId) === 36
                || Number(this.state.templateId) === 29   || Number(this.state.templateId) === 40|| Number(this.state.templateId) === 41||
                Number(this.state.templateId) === 42|| Number(this.state.templateId) === 43|| Number(this.state.templateId) === 44|| Number(this.state.templateId) === 45) &&
              <Fragment>
                <FormItem
                  {...formItemLayoutWithLabel}
                  label={(
                    <span>
               站点IMEI
            </span>
                  )}
                >
                  {getFieldDecorator('imei', {
                    initialValue: this.props.editRecord ? this.props.editRecord.imei : '',
                    rules: [{required: true, message: '请输入IMEI'}],
                  })(
                    <Input disabled={Boolean(this.props.editRecord)}/>,
                  )}
                </FormItem>
                {
                  this.props.editRecord &&
                  <FormItem
                    {...formItemLayoutWithLabel}
                    label={(
                      <span>
               站点IMSI
            </span>
                    )}
                  >
                    {getFieldDecorator('imsi', {
                      initialValue: this.props.editRecord ? this.props.editRecord.imsi : '',
                    })(
                      <Input disabled={Boolean(this.props.editRecord)}/>,
                    )}
                  </FormItem>
                }
              </Fragment>

            }
            {
              Number(this.state.templateId) === 1 &&
              <Form layout="inline" style={{paddingBottom: '50px'}}>
                <div className={styles.box_item} style={{paddingTop: '12px'}}>
                  <Tabs size='small' defaultActiveKey={'device'} style={{background: '#fafafa'}}>
                    <TabPane tab={'设备信息'} key={'device'}>

                      <Form.Item
                        label="数据上传间隔(分钟)"
                      >
                        <InputNumber
                          value={this.state.hardware_configs.device && this.state.hardware_configs.device[0].upload_interval}
                          onChange={(e) => {
                            if (!this.state.hardware_configs.device) {
                              this.state.hardware_configs.device = [];
                            }
                            if (this.state.hardware_configs.device.length < 1) {
                              this.state.hardware_configs.device[0] = {};
                              this.state.hardware_configs.device[0].upload_interval = e;
                            } else {
                              this.state.hardware_configs.device.splice(0, 1, {
                                ...this.state.hardware_configs.device[0],
                                upload_interval: e,
                              });
                            }
                            this.changeConfig({device: this.state.hardware_configs.device});
                          }}
                        />
                      </Form.Item>
                      <Form.Item
                        label="管径"
                      >
                        <Input
                          addonBefore="DN"
                          style={{width: '120px'}}
                          value={this.state.hardware_configs.customize && this.state.hardware_configs.customize.caliber}
                          onChange={(e) => {
                            if (!this.state.hardware_configs.customize) {
                              this.state.hardware_configs.customize = {}
                            }
                            this.state.hardware_configs.customize = {
                              ...this.state.hardware_configs.customize,
                              caliber: e.target.value
                            }
                            // console.log('this.state.hardware_configs.customize', this.state.hardware_configs.customize)
                            this.changeConfig({customize: this.state.hardware_configs.customize})
                          }}
                        />
                      </Form.Item>

                    </TabPane>
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'传感器1'} style={{background: '#fafafa'}}>
                    {
                      [{name: '传感器1'}, {name: '传感器2'}, {name: '传感器3'}, {name: '传感器4'}].map((item, index) => {

                        if (!(this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index].type)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          {
                            this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{name: '别名', key: 'alias'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item
                                  label={item2.name}>

                                <span>
                                 {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                </span>
                                </Form.Item>
                                <br/>
                              </Fragment>;

                            })
                          }


                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{name: '上传间隔(秒)', key: 'normal_upload_interval'}, {
                              name: `波动值(${this.state.hardware_configs.sensor[index].type === 'sensor001' ? 'Mpa' : 'm'})`,
                              key: 'fluctuation_value',
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>

                                  <br/>

                                </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            <Fragment><Form.Item
                              label="是否预警"
                            >
                              <Radio.Group
                                onChange={(e) => {
                                  if (!this.state.hardware_configs.sensor) {
                                    this.state.hardware_configs.sensor = [];
                                  }
                                  if (this.state.hardware_configs.sensor.length < 4) {
                                    if (this.state.hardware_configs.sensor[index]) {
                                      this.state.hardware_configs.sensor[index].alarm = e.target.value;
                                    } else {
                                      this.state.hardware_configs.sensor[index] = {};
                                      this.state.hardware_configs.sensor[index].alarm = e.target.value;
                                    }
                                  } else {
                                    this.state.hardware_configs.sensor.splice(index, 1, {
                                      ...this.state.hardware_configs.sensor[index],
                                      alarm: e.target.value,
                                    });
                                  }
                                  this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                }}
                                value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index].alarm}>
                                <Radio value={1}>报警</Radio>
                                <Radio value={0}>不报警</Radio>
                              </Radio.Group>
                            </Form.Item>
                              <br/>
                            </Fragment>
                          }

                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{
                              name: `${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '过压值(Mpa)' : '过高(m)'}`,
                              key: 'over'
                            }, {
                              name: `${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '欠压值(Mpa)' : '过低(m)'}`,
                              key: 'under',
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>
                                  {index2 === 2 && <br/>}
                                </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) && Boolean(this.state.hardware_configs.sensor[index].alarm) &&
                            [{
                              name: '报警间隔(秒)',
                              key: 'alarm_upload_interval',
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>

                                </Fragment>;

                            })
                          }


                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'Modbus1'} style={{background: '#fafafa'}}>
                    {
                      [{name: 'Modbus1'}, {name: 'Modbus2'}].map((item, index) => {
                        if (!(this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index].type)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          <Fragment><Form.Item
                            label='设备类型'>

                      <span>
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},
                              {key: 'DOUBLE-VALVE-PLC', name: '双阀PLC'},
                              {
                                key: 0,
                                name: '无',
                              }], o => o.key === this.state.hardware_configs.modbus_03[index].type) &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},
                              {key: 'DOUBLE-VALVE-PLC', name: '双阀PLC'},
                              {
                                key: 0,
                                name: '无',
                              }], o => o.key === this.state.hardware_configs.modbus_03[index].type).name}
                        </span>
                          </Form.Item>
                          </Fragment>
                          <br/>
                          {
                            this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '别名', key: 'alias'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >

                            <span>
                              {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                            </span>
                                </Form.Item>

                                <br/>

                              </Fragment>;

                            })
                          }


                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            this.state.hardware_configs.modbus_03[index].type === 'DOUBLE-VALVE-PLC' &&
                            <Fragment>
                              {
                                [{
                                  name: '蝶阀1动作',
                                  key: 'butterfly_valve1_status',
                                }, {
                                  name: '蝶阀2动作',
                                  key: 'butterfly_valve2_status',
                                }, {
                                  name: '蝶阀3动作',
                                  key: 'butterfly_valve3_status',
                                }, {
                                  name: '蝶阀4动作',
                                  key: 'butterfly_valve4_status',
                                }].map((item2, index2) => {
                                  return <Form.Item

                                    key={index2}
                                    label={item2.name}
                                  >
                                    <Select
                                      style={{width: '80px'}}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.modbus_03) {
                                          this.state.hardware_configs.modbus_03 = [];
                                        }
                                        if (this.state.hardware_configs.modbus_03.length < 4) {
                                          if (this.state.hardware_configs.modbus_03[index]) {
                                            this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.modbus_03[index] = {};
                                            this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.modbus_03.splice(index, 1, {
                                            ...this.state.hardware_configs.modbus_03[index],
                                            [item2.key]: e,
                                          });
                                        }
                                        this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                      }}

                                      value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    >
                                      {[{key: 1, name: '开'}, {key: 2, name: '停'}, {
                                        key: 4,
                                        name: '关',
                                      }].map((item, key) => {
                                        return (
                                          <Option key={key}
                                                  value={item.key}>{item.name}</Option>
                                        );
                                      })}
                                    </Select>
                                  </Form.Item>;

                                })

                              }
                            </Fragment>
                          }


                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'数字输入1'} style={{background: '#fafafa'}}>
                    {
                      [{name: '数字输入1'}, {name: '数字输入2'}].map((item, index) => {
                        if (!(this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index].enable)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          <Fragment>

                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].enable) &&
                              [{name: '别名', key: 'alias'}].map((item2, index2) => {
                                return <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >

                              <span>
                                {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                              </span>
                                  </Form.Item>

                                  <br/>

                                </Fragment>;

                              })}

                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) &&
                              [{name: '正常状态数据上传间隔(秒)', key: 'normal_upload_interval'}].map((item2, index2) => {
                                return (this.state.hardware_configs.digital_input[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                  <Fragment key={index2}>
                                    <Form.Item

                                      label={item2.name}
                                    >
                                      <InputNumber
                                        value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                                        onChange={(e) => {
                                          if (!this.state.hardware_configs.digital_input) {
                                            this.state.hardware_configs.digital_input = [];
                                          }
                                          if (this.state.hardware_configs.digital_input.length < 2) {
                                            if (this.state.hardware_configs.digital_input[index]) {
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            } else {
                                              this.state.hardware_configs.digital_input[index] = {};
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            }
                                          } else {
                                            this.state.hardware_configs.digital_input.splice(index, 1, {
                                              ...this.state.hardware_configs.digital_input[index],
                                              [item2.key]: e,
                                            });
                                          }


                                          this.changeConfig({digital_input: this.state.hardware_configs.digital_input});
                                        }}
                                      />
                                    </Form.Item>
                                    <br/>
                                  </Fragment>;

                              })
                            }
                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) &&
                              <Fragment><Form.Item
                                label="是否预警"
                              >
                                <Radio.Group onChange={(e) => {
                                  if (!this.state.hardware_configs.digital_input) {
                                    this.state.hardware_configs.digital_input = [];
                                  }
                                  if (this.state.hardware_configs.digital_input.length < 2) {
                                    if (this.state.hardware_configs.digital_input[index]) {
                                      this.state.hardware_configs.digital_input[index].alarm = e.target.value;
                                    } else {
                                      this.state.hardware_configs.digital_input[index] = {};
                                      this.state.hardware_configs.digital_input[index].alarm = e.target.value;
                                    }
                                  } else {
                                    this.state.hardware_configs.digital_input.splice(index, 1, {
                                      ...this.state.hardware_configs.digital_input[index],
                                      alarm: e.target.value,
                                    });
                                  }
                                  this.changeConfig({digital_input: this.state.hardware_configs.digital_input});
                                }}
                                             value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index].alarm}>
                                  <Radio value={1}>报警</Radio>
                                  <Radio value={0}>不报警</Radio>
                                </Radio.Group>
                              </Form.Item>
                                <br/>
                              </Fragment>
                            }
                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) && Boolean(this.state.hardware_configs.digital_input[index].alarm) &&
                              [{
                                name: '报警状态数据上传间隔(秒)',
                                key: 'alarm_upload_interval',
                              }].map((item2, index2) => {
                                return (this.state.hardware_configs.digital_input[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                  <Fragment key={index2}>
                                    <Form.Item

                                      label={item2.name}
                                    >
                                      <InputNumber
                                        value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                                        onChange={(e) => {
                                          if (!this.state.hardware_configs.digital_input) {
                                            this.state.hardware_configs.digital_input = [];
                                          }
                                          if (this.state.hardware_configs.digital_input.length < 2) {
                                            if (this.state.hardware_configs.digital_input[index]) {
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            } else {
                                              this.state.hardware_configs.digital_input[index] = {};
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            }
                                          } else {
                                            this.state.hardware_configs.digital_input.splice(index, 1, {
                                              ...this.state.hardware_configs.digital_input[index],
                                              [item2.key]: e,
                                            });
                                          }


                                          this.changeConfig({digital_input: this.state.hardware_configs.digital_input});
                                        }}
                                      />
                                    </Form.Item>

                                  </Fragment>;

                              })
                            }


                          </Fragment>


                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'调节阀1-1'} style={{background: '#fafafa'}}>
                    {
                      [{name: '调节阀1'}, {name: '调节阀2'}].map((item, index) => {
                        if (!(this.state.hardware_configs.control_valve && this.state.hardware_configs.control_valve[index] && this.state.hardware_configs.control_valve[index].enable)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          <Fragment>

                            {this.state.hardware_configs.control_valve && this.state.hardware_configs.control_valve[index] && Boolean(this.state.hardware_configs.control_valve[index].enable) &&
                              [{name: '别名', key: 'alias'}].map((item2, index2) => {
                                return <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >

                              <span>
                                {this.state.hardware_configs.control_valve && this.state.hardware_configs.control_valve[index] && this.state.hardware_configs.control_valve[index][item2.key]}
                              </span>
                                  </Form.Item>

                                  <br/>

                                </Fragment>;

                              })
                            }
                          </Fragment>

                          {this.state.hardware_configs.control_valve && this.state.hardware_configs.control_valve[index] && Boolean(this.state.hardware_configs.control_valve[index].enable) &&
                            <Fragment><Form.Item
                              label="设备编号"
                            >

                              <Input
                                value={this.state.hardware_configs.control_valve && this.state.hardware_configs.control_valve[index] && this.state.hardware_configs.control_valve[index].device_number}
                                onChange={(e) => {
                                  if (!this.state.hardware_configs.control_valve) {
                                    this.state.hardware_configs.control_valve = [];
                                  }
                                  if (this.state.hardware_configs.control_valve.length < 2) {
                                    if (this.state.hardware_configs.control_valve[index]) {
                                      this.state.hardware_configs.control_valve[index].device_number = e.target.value;
                                    } else {
                                      this.state.hardware_configs.control_valve[index] = {};
                                      this.state.hardware_configs.control_valve[index].device_number = e.target.value;
                                    }
                                  } else {
                                    this.state.hardware_configs.control_valve.splice(index, 1, {
                                      ...this.state.hardware_configs.control_valve[index],
                                      device_number: e.target.value,
                                    });
                                  }


                                  this.changeConfig({control_valve: this.state.hardware_configs.control_valve});
                                }}
                              />
                            </Form.Item></Fragment>
                          }
                          {
                            this.props.editRecord &&
                            <Fragment>
                              <Button type={'primary'} onClick={() => {
                                this.setState({
                                  device_number: this.state.hardware_configs.control_valve[index].device_number,
                                  config_index: index,
                                  configModal: true,
                                })
                              }}>调节阀配置</Button>
                            </Fragment>
                          }

                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>


              </Form>
            }
            {
              Number(this.state.templateId) === 2 &&
              <Form layout="inline" style={{paddingBottom: '50px'}}>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'流量计1'} style={{background: '#fafafa'}}>
                    {
                      [{name: '流量计'}].map((item, index) => {
                        if (!(this.state.hardware_configs.flowmeter && this.state.hardware_configs.flowmeter[index] && this.state.hardware_configs.flowmeter[index].enable)) {
                          console.log('false');
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          <Fragment>

                            {this.state.hardware_configs.flowmeter && this.state.hardware_configs.flowmeter[index] && Boolean(this.state.hardware_configs.flowmeter[index].enable) &&
                              [{name: '别名', key: 'alias'}].map((item2, index2) => {
                                return <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >

                              <span>
                                {this.state.hardware_configs.flowmeter && this.state.hardware_configs.flowmeter[index] && this.state.hardware_configs.flowmeter[index][item2.key]}
                              </span>
                                  </Form.Item>

                                  <br/>

                                </Fragment>;

                              })
                            }
                          </Fragment>

                          <Form.Item
                            label="设备编号"
                          >

                            <Input
                              value={this.state.hardware_configs.flowmeter && this.state.hardware_configs.flowmeter[index] && this.state.hardware_configs.flowmeter[index].device_number}
                              onChange={(e) => {
                                if (!this.state.hardware_configs.flowmeter) {
                                  this.state.hardware_configs.flowmeter = [];
                                }
                                if (this.state.hardware_configs.flowmeter.length < 2) {
                                  if (this.state.hardware_configs.flowmeter[index]) {
                                    this.state.hardware_configs.flowmeter[index].device_number = e.target.value;
                                  } else {
                                    this.state.hardware_configs.flowmeter[index] = {};
                                    this.state.hardware_configs.flowmeter[index].device_number = e.target.value;
                                  }
                                } else {
                                  this.state.hardware_configs.flowmeter.splice(index, 1, {
                                    ...this.state.hardware_configs.flowmeter[index],
                                    device_number: e.target.value,
                                  });
                                }


                                this.changeConfig({flowmeter: this.state.hardware_configs.flowmeter});
                              }}
                            />
                          </Form.Item>
                          <br/>
                          {
                            [{
                              name: '阀门状态',
                              key: 'valve_status',
                            }].map((item2, index2) => {
                              return <Form.Item

                                key={index2}
                                label={item2.name}
                              >
                                <Select
                                  style={{width: '80px'}}
                                  onChange={(e) => {
                                    if (!this.state.hardware_configs.flowmeter) {
                                      this.state.hardware_configs.flowmeter = [];
                                    }
                                    if (this.state.hardware_configs.flowmeter.length < 2) {
                                      if (this.state.hardware_configs.flowmeter[index]) {
                                        this.state.hardware_configs.flowmeter[index][item2.key] = e;
                                      } else {
                                        this.state.hardware_configs.flowmeter[index] = {};
                                        this.state.hardware_configs.flowmeter[index][item2.key] = e;
                                      }
                                    } else {
                                      this.state.hardware_configs.flowmeter.splice(index, 1, {
                                        ...this.state.hardware_configs.flowmeter[index],
                                        [item2.key]: e,
                                      });
                                    }
                                    this.changeConfig({flowmeter: this.state.hardware_configs.flowmeter});
                                  }}

                                  value={this.state.hardware_configs.flowmeter && this.state.hardware_configs.flowmeter[index] && this.state.hardware_configs.flowmeter[index][item2.key]}
                                >
                                  {[{key: 0, name: '关'}, {key: 1, name: '开'}].map((item, key) => {
                                    return (
                                      <Option key={key}
                                              value={item.key}>{item.name}</Option>
                                    );
                                  })}
                                </Select>
                              </Form.Item>;
                            })
                          }
                          {
                            [{
                              name: '数据上传间隔',
                              key: 'upload_interval',
                            }].map((item2, index2) => {
                              return <Form.Item

                                key={index2}
                                label={item2.name}
                              >
                                <Select
                                  style={{width: '160px'}}
                                  onChange={(e) => {
                                    if (!this.state.hardware_configs.flowmeter) {
                                      this.state.hardware_configs.flowmeter = [];
                                    }
                                    if (this.state.hardware_configs.flowmeter.length < 2) {
                                      if (this.state.hardware_configs.flowmeter[index]) {
                                        this.state.hardware_configs.flowmeter[index][item2.key] = e;
                                      } else {
                                        this.state.hardware_configs.flowmeter[index] = {};
                                        this.state.hardware_configs.flowmeter[index][item2.key] = e;
                                      }
                                    } else {
                                      this.state.hardware_configs.flowmeter.splice(index, 1, {
                                        ...this.state.hardware_configs.flowmeter[index],
                                        [item2.key]: e,
                                      });
                                    }
                                    this.changeConfig({flowmeter: this.state.hardware_configs.flowmeter});
                                  }}

                                  value={this.state.hardware_configs.flowmeter && this.state.hardware_configs.flowmeter[index] && this.state.hardware_configs.flowmeter[index][item2.key]}
                                >
                                  {[{key: 1, name: '每天1次'}, {key: 2, name: '12小时1次'},
                                    {key: 3, name: '8小时1次'}, {key: 4, name: '6小时1次'},
                                    {key: 5, name: '4小时1次'}, {key: 6, name: '3小时1次'},
                                    {key: 7, name: '2小时1次'}, {key: 8, name: '1小时1次'},
                                    {key: 9, name: '30分钟1次'}, {key: 10, name: '15分钟1次'},
                                    {key: 11, name: '5分钟1次'}, {key: 12, name: '1分钟1次'}].map((item, key) => {
                                    return (
                                      <Option key={key}
                                              value={item.key}>{item.name}</Option>
                                    );
                                  })}
                                </Select>
                              </Form.Item>;
                            })
                          }
                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>


              </Form>
            }
            {
              Number(this.state.templateId) === 3 &&
              <Form layout="inline" style={{paddingBottom: '50px'}}>
                <div className={styles.box_item} style={{paddingTop: '12px'}}>
                  <Tabs size='small' defaultActiveKey={'device'} style={{background: '#fafafa'}}>
                    <TabPane tab={'设备信息'} key={'device'}>

                      <Form.Item
                        label="数据上传间隔(分钟)"
                      >
                        <InputNumber
                          value={this.state.hardware_configs.device && this.state.hardware_configs.device[0].upload_interval}
                          onChange={(e) => {
                            if (!this.state.hardware_configs.device) {
                              this.state.hardware_configs.device = [];
                            }
                            if (this.state.hardware_configs.device.length < 1) {
                              this.state.hardware_configs.device[0] = {};
                              this.state.hardware_configs.device[0].upload_interval = e;
                            } else {
                              this.state.hardware_configs.device.splice(0, 1, {
                                ...this.state.hardware_configs.device[0],
                                upload_interval: e,
                              });
                            }
                            this.changeConfig({device: this.state.hardware_configs.device});
                          }}
                        />
                      </Form.Item>

                    </TabPane>
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'Modbus1'} style={{background: '#fafafa'}}>
                    {
                      [{name: 'Modbus1'}, {name: 'Modbus2'}].map((item, index) => {
                        if (!(this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index].type)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          <Fragment><Form.Item
                            label='设备类型'>

                      <span>
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},
                              {key: 'DOUBLE-VALVE-PLC', name: '双阀PLC'},
                              {key: 'CHEMITEC-50-SERIES', name: '水质检测'},
                              {
                                key: 0,
                                name: '无',
                              }], o => o.key === this.state.hardware_configs.modbus_03[index].type) &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},
                              {key: 'DOUBLE-VALVE-PLC', name: '双阀PLC'},
                              {key: 'CHEMITEC-50-SERIES', name: '水质检测'},
                              {
                                key: 0,
                                name: '无',
                              }], o => o.key === this.state.hardware_configs.modbus_03[index].type).name}
                        </span>
                          </Form.Item>
                          </Fragment>
                          <br/>
                          {/* {
                            this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{ name: '别名', key: 'alias' }].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >

                            <span>
                              {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                            </span>
                                </Form.Item>

                                <br/>

                              </Fragment>;

                            })
                          }*/}


                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            this.state.hardware_configs.modbus_03[index].type === 'CHEMITEC-50-SERIES' &&
                            <Fragment>
                              {
                                [{
                                  name: '通道1接入类型',
                                  key: 'channel1_type',
                                }, {
                                  name: '通道2接入类型',
                                  key: 'channel2_type',
                                }, {
                                  name: '通道3接入类型',
                                  key: 'channel3_type',
                                }, {
                                  name: '通道4接入类型',
                                  key: 'channel4_type',
                                }].map((item2, index2) => {
                                  return <Form.Item

                                    key={index2}
                                    label={item2.name}
                                  >
                                    <Select
                                      style={{width: '80px'}}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.modbus_03) {
                                          this.state.hardware_configs.modbus_03 = [];
                                        }
                                        if (this.state.hardware_configs.modbus_03.length < 4) {
                                          if (this.state.hardware_configs.modbus_03[index]) {
                                            this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.modbus_03[index] = {};
                                            this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.modbus_03.splice(index, 1, {
                                            ...this.state.hardware_configs.modbus_03[index],
                                            [item2.key]: e,
                                          });
                                        }
                                        this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                      }}

                                      value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    >
                                      {[{
                                        key: 0,
                                        name: '禁用',
                                      }, {key: 1, name: 'PH值'}, {key: 2, name: '浊度'}, {
                                        key: 3,
                                        name: '溶氧',
                                      }, {
                                        key: 4,
                                        name: '电导率',
                                      }, {
                                        key: 5,
                                        name: '余氯',
                                      }].map((item, key) => {
                                        return (
                                          <Option key={key}
                                                  value={item.key}>{item.name}</Option>
                                        );
                                      })}
                                    </Select>
                                  </Form.Item>;

                                })

                              }
                            </Fragment>
                          }
                          <br/>
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '数据上传间隔(秒)', key: 'upload_interval'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >
                                  <InputNumber
                                    value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    onChange={(e) => {
                                      if (!this.state.hardware_configs.modbus_03) {
                                        this.state.hardware_configs.modbus_03 = [];
                                      }
                                      if (this.state.hardware_configs.modbus_03.length < 2) {
                                        if (this.state.hardware_configs.modbus_03[index]) {
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        } else {
                                          this.state.hardware_configs.modbus_03[index] = {};
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        }
                                      } else {
                                        this.state.hardware_configs.modbus_03.splice(index, 1, {
                                          ...this.state.hardware_configs.modbus_03[index],
                                          [item2.key]: e,
                                        });
                                      }


                                      this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                    }}
                                  />
                                </Form.Item>
                                <br/>
                              </Fragment>;

                            })
                          }

                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
              </Form>
            }
            {
              Number(this.state.templateId) === 4 &&
              <Form layout="inline" style={{paddingBottom: '50px'}}>
                <div className={styles.box_item} style={{paddingTop: '12px'}}>
                  <Tabs size='small' defaultActiveKey={'device'} style={{background: '#fafafa'}}>
                    <TabPane tab={'设备信息'} key={'device'}>

                      <Form.Item
                        label="数据上传间隔(分钟)"
                      >
                        <InputNumber
                          value={this.state.hardware_configs.device && this.state.hardware_configs.device[0].upload_interval}
                          onChange={(e) => {
                            if (!this.state.hardware_configs.device) {
                              this.state.hardware_configs.device = [];
                            }
                            if (this.state.hardware_configs.device.length < 1) {
                              this.state.hardware_configs.device[0] = {};
                              this.state.hardware_configs.device[0].upload_interval = e;
                            } else {
                              this.state.hardware_configs.device.splice(0, 1, {
                                ...this.state.hardware_configs.device[0],
                                upload_interval: e,
                              });
                            }
                            this.changeConfig({device: this.state.hardware_configs.device});
                          }}
                        />
                      </Form.Item>

                    </TabPane>
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'Modbus1'} style={{background: '#fafafa'}}>
                    {
                      [{name: 'Modbus1'}, {name: 'Modbus2'}].map((item, index) => {
                        if (!(this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index].type)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          <Fragment><Form.Item
                            label='设备类型'>

                      <span>
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},
                              {key: 'DOUBLE-VALVE-PLC', name: '双阀PLC'},
                              {key: 'CHEMITEC-50-SERIES', name: '水质检测'},
                              {key: 'Modbus010', name: '电磁计量器'},
                              {
                                key: 0,
                                name: '无',
                              }], o => o.key === this.state.hardware_configs.modbus_03[index].type) &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},
                              {key: 'DOUBLE-VALVE-PLC', name: '双阀PLC'},
                              {key: 'CHEMITEC-50-SERIES', name: '水质检测'},
                              {key: 'Modbus010', name: '电磁计量器'},
                              {
                                key: 0,
                                name: '无',
                              }], o => o.key === this.state.hardware_configs.modbus_03[index].type).name}
                        </span>
                          </Form.Item>
                          </Fragment>
                          <br/>
                          {
                            this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '别名', key: 'alias'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >

                            <span>
                              {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                            </span>
                                </Form.Item>

                                <br/>

                              </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '数据上传间隔(秒)', key: 'upload_interval'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >
                                  <InputNumber
                                    value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    onChange={(e) => {
                                      if (!this.state.hardware_configs.modbus_03) {
                                        this.state.hardware_configs.modbus_03 = [];
                                      }
                                      if (this.state.hardware_configs.modbus_03.length < 2) {
                                        if (this.state.hardware_configs.modbus_03[index]) {
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        } else {
                                          this.state.hardware_configs.modbus_03[index] = {};
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        }
                                      } else {
                                        this.state.hardware_configs.modbus_03.splice(index, 1, {
                                          ...this.state.hardware_configs.modbus_03[index],
                                          [item2.key]: e,
                                        });
                                      }


                                      this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                    }}
                                  />
                                </Form.Item>
                                <br/>
                              </Fragment>;

                            })
                          }

                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '最低瞬时流量报警值', key: 'min_instantaneous_flow'}, {
                              name: '最高瞬时流量报警值',
                              key: 'max_instantaneous_flow'
                            }].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item
                                  help={'填数字或者"-"，值为"-"时关闭报警'}
                                  label={item2.name}
                                  style={{marginBottom: '0'}}
                                >
                                  <Input
                                    value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    onChange={(e) => {
                                      if (!this.state.hardware_configs.modbus_03) {
                                        this.state.hardware_configs.modbus_03 = [];
                                      }
                                      if (this.state.hardware_configs.modbus_03.length < 2) {
                                        if (this.state.hardware_configs.modbus_03[index]) {
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e.target.value;
                                        } else {
                                          this.state.hardware_configs.modbus_03[index] = {};
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e.target.value;
                                        }
                                      } else {
                                        this.state.hardware_configs.modbus_03.splice(index, 1, {
                                          ...this.state.hardware_configs.modbus_03[index],
                                          [item2.key]: e.target.value,
                                        });
                                      }


                                      this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                    }}
                                  />
                                </Form.Item>
                              </Fragment>;

                            })
                          }

                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
              </Form>
            }
            {
              Number(this.state.templateId) === 5 &&
              <Form layout="inline" style={{paddingBottom: '50px'}}>
                <div className={styles.box_item} style={{paddingTop: '12px'}}>
                  <Tabs size='small' defaultActiveKey={'device'} style={{background: '#fafafa'}}>
                    <TabPane tab={'设备信息'} key={'device'}>

                      <Form.Item
                        label="数据上传间隔(分钟)"
                      >
                        <InputNumber
                          value={this.state.hardware_configs.device && this.state.hardware_configs.device[0].upload_interval}
                          onChange={(e) => {
                            if (!this.state.hardware_configs.device) {
                              this.state.hardware_configs.device = [];
                            }
                            if (this.state.hardware_configs.device.length < 1) {
                              this.state.hardware_configs.device[0] = {};
                              this.state.hardware_configs.device[0].upload_interval = e;
                            } else {
                              this.state.hardware_configs.device.splice(0, 1, {
                                ...this.state.hardware_configs.device[0],
                                upload_interval: e,
                              });
                            }
                            this.changeConfig({device: this.state.hardware_configs.device});
                          }}
                        />
                      </Form.Item>

                    </TabPane>
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'Modbus1'} style={{background: '#fafafa'}}>
                    {
                      [{name: 'Modbus1'}].map((item, index) => {
                        if (!(this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index].type)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          <Fragment><Form.Item
                            label='设备类型'>

                      <span>
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},
                              {key: 'DOUBLE-VALVE-PLC', name: '双阀PLC'},
                              {key: 'CHEMITEC-50-SERIES', name: '水质检测'},
                              {key: 'Modbus010', name: '电磁计量器'},
                              {key: 'Modbus011', name: 'Modbus011'},
                              {key: 'Modbus012', name: 'Modbus012'},
                              {
                                key: 0,
                                name: '无',
                              }], o => o.key === this.state.hardware_configs.modbus_03[index].type) &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},
                              {key: 'DOUBLE-VALVE-PLC', name: '双阀PLC'},
                              {key: 'CHEMITEC-50-SERIES', name: '水质检测'},
                              {key: 'Modbus010', name: '电磁计量器'},
                              {key: 'Modbus011', name: 'Modbus011'},
                              {key: 'Modbus012', name: 'Modbus012'},
                              {
                                key: 0,
                                name: '无',
                              }], o => o.key === this.state.hardware_configs.modbus_03[index].type).name}
                        </span>
                          </Form.Item>
                          </Fragment>
                          <br/>
                          {
                            this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '别名', key: 'alias'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >

                            <span>
                              {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                            </span>
                                </Form.Item>

                                <br/>

                              </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '数据上传间隔(秒)', key: 'upload_interval'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >
                                  <InputNumber
                                    value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    onChange={(e) => {
                                      if (!this.state.hardware_configs.modbus_03) {
                                        this.state.hardware_configs.modbus_03 = [];
                                      }
                                      if (this.state.hardware_configs.modbus_03.length < 2) {
                                        if (this.state.hardware_configs.modbus_03[index]) {
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        } else {
                                          this.state.hardware_configs.modbus_03[index] = {};
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        }
                                      } else {
                                        this.state.hardware_configs.modbus_03.splice(index, 1, {
                                          ...this.state.hardware_configs.modbus_03[index],
                                          [item2.key]: e,
                                        });
                                      }


                                      this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                    }}
                                  />
                                </Form.Item>
                                <br/>
                              </Fragment>;

                            })
                          }

                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '最低瞬时流量报警值', key: 'min_instantaneous_flow'}, {
                              name: '最高瞬时流量报警值',
                              key: 'max_instantaneous_flow'
                            }].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item
                                  help={'填数字或者"-"，值为"-"时关闭报警'}
                                  label={item2.name}
                                  style={{marginBottom: '0'}}
                                >
                                  <Input
                                    value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    onChange={(e) => {
                                      if (!this.state.hardware_configs.modbus_03) {
                                        this.state.hardware_configs.modbus_03 = [];
                                      }
                                      if (this.state.hardware_configs.modbus_03.length < 2) {
                                        if (this.state.hardware_configs.modbus_03[index]) {
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e.target.value;
                                        } else {
                                          this.state.hardware_configs.modbus_03[index] = {};
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e.target.value;
                                        }
                                      } else {
                                        this.state.hardware_configs.modbus_03.splice(index, 1, {
                                          ...this.state.hardware_configs.modbus_03[index],
                                          [item2.key]: e.target.value,
                                        });
                                      }


                                      this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                    }}
                                  />
                                </Form.Item>
                              </Fragment>;

                            })
                          }

                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
              </Form>
            }
            {
              Number(this.state.templateId) === 6 &&
              <Form layout="inline" style={{paddingBottom: '50px'}}>
                <div className={styles.box_item} style={{paddingTop: '12px'}}>
                  <Tabs size='small' defaultActiveKey={'device'} style={{background: '#fafafa'}}>
                    <TabPane tab={'设备信息'} key={'device'}>

                      <Form.Item
                        label="数据上传间隔(分钟)"
                      >
                        <InputNumber
                          value={this.state.hardware_configs.device && this.state.hardware_configs.device[0].upload_interval}
                          onChange={(e) => {
                            if (!this.state.hardware_configs.device) {
                              this.state.hardware_configs.device = [];
                            }
                            if (this.state.hardware_configs.device.length < 1) {
                              this.state.hardware_configs.device[0] = {};
                              this.state.hardware_configs.device[0].upload_interval = e;
                            } else {
                              this.state.hardware_configs.device.splice(0, 1, {
                                ...this.state.hardware_configs.device[0],
                                upload_interval: e,
                              });
                            }
                            this.changeConfig({device: this.state.hardware_configs.device});
                          }}
                        />
                      </Form.Item>

                    </TabPane>
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'Modbus1'} style={{background: '#fafafa'}}>
                    {
                      [{name: 'Modbus1'}].map((item, index) => {
                        if (!(this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index].type)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          <Fragment><Form.Item
                            label='设备类型'>

                      <span>
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},
                              {key: 'DOUBLE-VALVE-PLC', name: '双阀PLC'},
                              {key: 'CHEMITEC-50-SERIES', name: '水质检测'},
                              {key: 'Modbus010', name: '电磁计量器'},
                              {key: 'Modbus011', name: 'Modbus011'},
                              {key: 'Modbus012', name: 'Modbus012'},
                              {
                                key: 0,
                                name: '无',
                              }], o => o.key === this.state.hardware_configs.modbus_03[index].type) &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},
                              {key: 'DOUBLE-VALVE-PLC', name: '双阀PLC'},
                              {key: 'CHEMITEC-50-SERIES', name: '水质检测'},
                              {key: 'Modbus010', name: '电磁计量器'},
                              {key: 'Modbus011', name: 'Modbus011'},
                              {key: 'Modbus012', name: 'Modbus012'},
                              {
                                key: 0,
                                name: '无',
                              }], o => o.key === this.state.hardware_configs.modbus_03[index].type).name}
                        </span>
                          </Form.Item>
                          </Fragment>
                          <br/>
                          {
                            this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '别名', key: 'alias'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >

                            <span>
                              {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                            </span>
                                </Form.Item>

                                <br/>

                              </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '数据上传间隔(秒)', key: 'upload_interval'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >
                                  <InputNumber
                                    value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    onChange={(e) => {
                                      if (!this.state.hardware_configs.modbus_03) {
                                        this.state.hardware_configs.modbus_03 = [];
                                      }
                                      if (this.state.hardware_configs.modbus_03.length < 2) {
                                        if (this.state.hardware_configs.modbus_03[index]) {
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        } else {
                                          this.state.hardware_configs.modbus_03[index] = {};
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        }
                                      } else {
                                        this.state.hardware_configs.modbus_03.splice(index, 1, {
                                          ...this.state.hardware_configs.modbus_03[index],
                                          [item2.key]: e,
                                        });
                                      }


                                      this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                    }}
                                  />
                                </Form.Item>
                                <br/>
                              </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '最低瞬时流量报警值', key: 'min_instantaneous_flow'}, {
                              name: '最高瞬时流量报警值',
                              key: 'max_instantaneous_flow'
                            }].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item
                                  help={'填数字或者"-"，值为"-"时关闭报警'}
                                  label={item2.name}
                                  style={{marginBottom: '0'}}
                                >
                                  <Input
                                    value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    onChange={(e) => {
                                      if (!this.state.hardware_configs.modbus_03) {
                                        this.state.hardware_configs.modbus_03 = [];
                                      }
                                      if (this.state.hardware_configs.modbus_03.length < 2) {
                                        if (this.state.hardware_configs.modbus_03[index]) {
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e.target.value;
                                        } else {
                                          this.state.hardware_configs.modbus_03[index] = {};
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e.target.value;
                                        }
                                      } else {
                                        this.state.hardware_configs.modbus_03.splice(index, 1, {
                                          ...this.state.hardware_configs.modbus_03[index],
                                          [item2.key]: e.target.value,
                                        });
                                      }


                                      this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                    }}
                                  />
                                </Form.Item>
                              </Fragment>;

                            })
                          }

                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
              </Form>
            }
            {
              Number(this.state.templateId) === 7 &&
              <Form layout="inline" style={{paddingBottom: '50px'}}>
                <div className={styles.box_item} style={{paddingTop: '12px'}}>
                  <Tabs size='small' defaultActiveKey={'device'} style={{background: '#fafafa'}}>
                    <TabPane tab={'设备信息'} key={'device'}>

                      <Form.Item
                        label="数据上传间隔(分钟)"
                      >
                        <InputNumber
                          value={this.state.hardware_configs.device && this.state.hardware_configs.device[0].upload_interval}
                          onChange={(e) => {
                            if (!this.state.hardware_configs.device) {
                              this.state.hardware_configs.device = [];
                            }
                            if (this.state.hardware_configs.device.length < 1) {
                              this.state.hardware_configs.device[0] = {};
                              this.state.hardware_configs.device[0].upload_interval = e;
                            } else {
                              this.state.hardware_configs.device.splice(0, 1, {
                                ...this.state.hardware_configs.device[0],
                                upload_interval: e,
                              });
                            }
                            this.changeConfig({device: this.state.hardware_configs.device});
                          }}
                        />
                      </Form.Item>

                    </TabPane>
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'Modbus1'} style={{background: '#fafafa'}}>
                    {
                      [{name: 'Modbus1'}].map((item, index) => {
                        if (!(this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index].type)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          <Fragment><Form.Item
                            label='设备类型'>

                      <span>
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},
                              {key: 'DOUBLE-VALVE-PLC', name: '双阀PLC'},
                              {key: 'CHEMITEC-50-SERIES', name: '水质检测'},
                              {key: 'Modbus010', name: '电磁计量器'},
                              {key: 'Modbus011', name: 'Modbus011'},
                              {key: 'Modbus012', name: 'Modbus012'},
                              {key: 'Modbus013', name: 'Modbus013'},
                              {
                                key: 0,
                                name: '无',
                              }], o => o.key === this.state.hardware_configs.modbus_03[index].type) &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},
                              {key: 'DOUBLE-VALVE-PLC', name: '双阀PLC'},
                              {key: 'CHEMITEC-50-SERIES', name: '水质检测'},
                              {key: 'Modbus010', name: '电磁计量器'},
                              {key: 'Modbus011', name: 'Modbus011'},
                              {key: 'Modbus012', name: 'Modbus012'},
                              {key: 'Modbus013', name: 'Modbus013'},
                              {
                                key: 0,
                                name: '无',
                              }], o => o.key === this.state.hardware_configs.modbus_03[index].type).name}
                        </span>
                          </Form.Item>
                          </Fragment>
                          <br/>
                          {
                            this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '别名', key: 'alias'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >

                            <span>
                              {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                            </span>
                                </Form.Item>

                                <br/>

                              </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '数据上传间隔(秒)', key: 'upload_interval'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >
                                  <InputNumber
                                    value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    onChange={(e) => {
                                      if (!this.state.hardware_configs.modbus_03) {
                                        this.state.hardware_configs.modbus_03 = [];
                                      }
                                      if (this.state.hardware_configs.modbus_03.length < 2) {
                                        if (this.state.hardware_configs.modbus_03[index]) {
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        } else {
                                          this.state.hardware_configs.modbus_03[index] = {};
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        }
                                      } else {
                                        this.state.hardware_configs.modbus_03.splice(index, 1, {
                                          ...this.state.hardware_configs.modbus_03[index],
                                          [item2.key]: e,
                                        });
                                      }


                                      this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                    }}
                                  />
                                </Form.Item>
                                <br/>
                              </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '最低瞬时流量报警值', key: 'min_instantaneous_flow'}, {
                              name: '最高瞬时流量报警值',
                              key: 'max_instantaneous_flow'
                            }].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item
                                  help={'填数字或者"-"，值为"-"时关闭报警'}
                                  label={item2.name}
                                  style={{marginBottom: '0'}}
                                >
                                  <Input
                                    value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    onChange={(e) => {
                                      if (!this.state.hardware_configs.modbus_03) {
                                        this.state.hardware_configs.modbus_03 = [];
                                      }
                                      if (this.state.hardware_configs.modbus_03.length < 2) {
                                        if (this.state.hardware_configs.modbus_03[index]) {
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e.target.value;
                                        } else {
                                          this.state.hardware_configs.modbus_03[index] = {};
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e.target.value;
                                        }
                                      } else {
                                        this.state.hardware_configs.modbus_03.splice(index, 1, {
                                          ...this.state.hardware_configs.modbus_03[index],
                                          [item2.key]: e.target.value,
                                        });
                                      }


                                      this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                    }}
                                  />
                                </Form.Item>
                              </Fragment>;

                            })
                          }

                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
              </Form>
            }
            {
              Number(this.state.templateId) === 8 &&
              <Form layout="inline" style={{paddingBottom: '50px'}}>
                <div className={styles.box_item} style={{paddingTop: '12px'}}>
                  <Tabs size='small' defaultActiveKey={'device'} style={{background: '#fafafa'}}>
                    <TabPane tab={'设备信息'} key={'device'}>

                      <Form.Item
                        label="数据上传间隔(分钟)"
                      >
                        <InputNumber
                          value={this.state.hardware_configs.device && this.state.hardware_configs.device[0].upload_interval}
                          onChange={(e) => {
                            if (!this.state.hardware_configs.device) {
                              this.state.hardware_configs.device = [];
                            }
                            if (this.state.hardware_configs.device.length < 1) {
                              this.state.hardware_configs.device[0] = {};
                              this.state.hardware_configs.device[0].upload_interval = e;
                            } else {
                              this.state.hardware_configs.device.splice(0, 1, {
                                ...this.state.hardware_configs.device[0],
                                upload_interval: e,
                              });
                            }
                            this.changeConfig({device: this.state.hardware_configs.device});
                          }}
                        />
                      </Form.Item>

                    </TabPane>
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'Modbus'} style={{background: '#fafafa'}}>
                    <TabPane tab={'Modbus'} key={'Modbus'}>
                      <Form.Item

                        label={'Modbus数据上传时间(秒)'}
                      >
                        <InputNumber
                          value={this.state.hardware_configs.modbus_03 &&
                            this.state.hardware_configs.modbus_03[0] &&
                            this.state.hardware_configs.modbus_03[0].upload_interval}
                          onChange={(e) => {
                            this.state.hardware_configs.modbus_03[0].upload_interval = e;
                            this.state.hardware_configs.modbus_03[1].upload_interval = e;
                            this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                          }}
                        />
                      </Form.Item>
                    </TabPane>
                  </Tabs>
                </div>
              </Form>
            }
            {
              Number(this.state.templateId) === 9 &&
              <Form layout="inline" style={{paddingBottom: '50px'}}>
                <div className={styles.box_item} style={{paddingTop: '12px'}}>
                  <Tabs size='small' defaultActiveKey={'device'} style={{background: '#fafafa'}}>
                    <TabPane tab={'设备信息'} key={'device'}>

                      <Form.Item
                        label="数据上传间隔(分钟)"
                      >
                        <InputNumber
                          value={this.state.hardware_configs.device && this.state.hardware_configs.device[0].upload_interval}
                          onChange={(e) => {
                            if (!this.state.hardware_configs.device) {
                              this.state.hardware_configs.device = [];
                            }
                            if (this.state.hardware_configs.device.length < 1) {
                              this.state.hardware_configs.device[0] = {};
                              this.state.hardware_configs.device[0].upload_interval = e;
                            } else {
                              this.state.hardware_configs.device.splice(0, 1, {
                                ...this.state.hardware_configs.device[0],
                                upload_interval: e,
                              });
                            }
                            this.changeConfig({device: this.state.hardware_configs.device});
                          }}
                        />
                      </Form.Item>
                      <Form.Item
                        label="管径"
                      >
                        <Input
                          addonBefore="DN"
                          style={{width: '120px'}}
                          value={this.state.hardware_configs.customize && this.state.hardware_configs.customize.caliber}
                          onChange={(e) => {
                            if (!this.state.hardware_configs.customize) {
                              this.state.hardware_configs.customize = {}
                            }
                            this.state.hardware_configs.customize = {
                              ...this.state.hardware_configs.customize,
                              caliber: e.target.value
                            }
                            // console.log('this.state.hardware_configs.customize', this.state.hardware_configs.customize)
                            this.changeConfig({customize: this.state.hardware_configs.customize})
                          }}
                        />
                      </Form.Item>

                    </TabPane>
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'Modbus1'} style={{background: '#fafafa'}}>
                    {
                      [{name: 'Modbus1'}, {name: 'Modbus2'}].map((item, index) => {
                        if (!(this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index].type)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          <Fragment><Form.Item
                            label='设备类型'>

                      <span>
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},
                              {key: 'DOUBLE-VALVE-PLC', name: '双阀PLC'},
                              {key: 'Modbus015_1', name: 'Modbus015_1'},
                              {key: 'Modbus015_2', name: 'Modbus015_2'},
                              {
                                key: 0,
                                name: '无',
                              }], o => o.key === this.state.hardware_configs.modbus_03[index].type) &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},
                              {key: 'DOUBLE-VALVE-PLC', name: '双阀PLC'},
                              {key: 'Modbus015_1', name: 'Modbus015_1'},
                              {key: 'Modbus015_2', name: 'Modbus015_2'},
                              {
                                key: 0,
                                name: '无',
                              }], o => o.key === this.state.hardware_configs.modbus_03[index].type).name}
                        </span>
                          </Form.Item>
                          </Fragment>
                          <br/>
                          {
                            this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '别名', key: 'alias'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >

                            <span>
                              {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                            </span>
                                </Form.Item>

                                <br/>

                              </Fragment>;

                            })
                          }


                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            this.state.hardware_configs.modbus_03[index].type === 'Modbus015_1' &&
                            <Fragment>
                              {
                                [{
                                  name: '蝶阀1动作',
                                  key: 'butterfly_valve1_status',
                                }, {
                                  name: '蝶阀2动作',
                                  key: 'butterfly_valve2_status',
                                }, {
                                  name: '蝶阀3动作',
                                  key: 'butterfly_valve3_status',
                                }, {
                                  name: '蝶阀4动作',
                                  key: 'butterfly_valve4_status',
                                }].map((item2, index2) => {
                                  return <Form.Item

                                    key={index2}
                                    label={item2.name}
                                  >
                                    <Select
                                      style={{width: '80px'}}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.modbus_03) {
                                          this.state.hardware_configs.modbus_03 = [];
                                        }
                                        if (this.state.hardware_configs.modbus_03.length < 4) {
                                          if (this.state.hardware_configs.modbus_03[index]) {
                                            this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.modbus_03[index] = {};
                                            this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.modbus_03.splice(index, 1, {
                                            ...this.state.hardware_configs.modbus_03[index],
                                            [item2.key]: e,
                                          });
                                        }
                                        this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                      }}

                                      value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    >
                                      {[{key: 1, name: '开'}, {key: 2, name: '停'}, {
                                        key: 4,
                                        name: '关',
                                      }].map((item, key) => {
                                        return (
                                          <Option key={key}
                                                  value={item.key}>{item.name}</Option>
                                        );
                                      })}
                                    </Select>
                                  </Form.Item>;

                                })

                              }
                            </Fragment>
                          }
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            this.state.hardware_configs.modbus_03[index].type === 'Modbus015_2' &&
                            [{name: '压力设置值(MPa)', key: 'pressure_valve_pressure_limit_value'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >
                                  <InputNumber
                                    value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    onChange={(e) => {
                                      if (!this.state.hardware_configs.modbus_03) {
                                        this.state.hardware_configs.modbus_03 = [];
                                      }
                                      if (this.state.hardware_configs.modbus_03.length < 2) {
                                        if (this.state.hardware_configs.modbus_03[index]) {
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        } else {
                                          this.state.hardware_configs.modbus_03[index] = {};
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        }
                                      } else {
                                        this.state.hardware_configs.modbus_03.splice(index, 1, {
                                          ...this.state.hardware_configs.modbus_03[index],
                                          [item2.key]: e,
                                        });
                                      }


                                      this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                    }}
                                  />
                                </Form.Item>
                              </Fragment>;

                            })
                          }
                          <br/>
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '数据上传间隔(秒)', key: 'upload_interval'}].map((item2, index2) => {
                              console.log('index', index)
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >
                                  <InputNumber
                                    value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    onChange={(e) => {
                                      if (!this.state.hardware_configs.modbus_03) {
                                        this.state.hardware_configs.modbus_03 = [];
                                      }
                                      if (this.state.hardware_configs.modbus_03.length < 2) {
                                        if (this.state.hardware_configs.modbus_03[index]) {
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        } else {
                                          this.state.hardware_configs.modbus_03[index] = {};
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        }
                                      } else {
                                        this.state.hardware_configs.modbus_03.splice(index, 1, {
                                          ...this.state.hardware_configs.modbus_03[index],
                                          [item2.key]: e,
                                        });
                                      }


                                      this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                    }}
                                  />
                                </Form.Item>
                                <br/>
                              </Fragment>;

                            })
                          }

                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'传感器1'} style={{background: '#fafafa'}}>
                    {
                      !(this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[0] && this.state.hardware_configs.sensor[0].type) &&
                      <Button type={'primary'} onClick={()=>{
                        this.state.hardware_configs.sensor[0].type = 'sensor002';
                        this.state.hardware_configs.sensor[0].alias = '液位';
                        this.state.hardware_configs.sensor[0].normal_upload_interval = 900;
                        this.state.hardware_configs.sensor[0].alarm_upload_interval = 30;
                        this.state.hardware_configs.sensor[0].fluctuation_value = 0;
                        this.state.hardware_configs.sensor[0].alarm = 1;
                        this.state.hardware_configs.sensor[0].over = 0.7;
                        this.state.hardware_configs.sensor[0].over_cancel = 0.7;
                        this.state.hardware_configs.sensor[0].under = 0.3;
                        this.state.hardware_configs.sensor[0].under_cancel = 0.3;
                        this.setState({
                          hardware_configs:this.state.hardware_configs
                        })
                      }}>添加传感器</Button>

                    }
                    {
                      [{name: '传感器1'}, {name: '传感器2'}, {name: '传感器3'}, {name: '传感器4'}].map((item, index) => {

                        if (!(this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index].type)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          {
                            this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{name: '别名', key: 'alias'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item
                                  label={item2.name}>

                                <span>
                                 {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                </span>
                                </Form.Item>
                                <br/>
                              </Fragment>;

                            })
                          }


                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{name: '上传间隔(秒)', key: 'normal_upload_interval'}, {
                              name: `波动值(${this.state.hardware_configs.sensor[index].type === 'sensor001' ? 'Mpa' : 'm'})`,
                              key: 'fluctuation_value',
                            }, {
                              name: `满量程${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '(Mpa)' : '(m)'}`,
                              key: 'range_max'
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>

                                  <br/>

                                </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            <Fragment><Form.Item
                              label="是否预警"
                            >
                              <Radio.Group
                                onChange={(e) => {
                                  if (!this.state.hardware_configs.sensor) {
                                    this.state.hardware_configs.sensor = [];
                                  }
                                  if (this.state.hardware_configs.sensor.length < 4) {
                                    if (this.state.hardware_configs.sensor[index]) {
                                      this.state.hardware_configs.sensor[index].alarm = e.target.value;
                                    } else {
                                      this.state.hardware_configs.sensor[index] = {};
                                      this.state.hardware_configs.sensor[index].alarm = e.target.value;
                                    }
                                  } else {
                                    this.state.hardware_configs.sensor.splice(index, 1, {
                                      ...this.state.hardware_configs.sensor[index],
                                      alarm: e.target.value,
                                    });
                                  }
                                  this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                }}
                                value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index].alarm}>
                                <Radio value={1}>报警</Radio>
                                <Radio value={0}>不报警</Radio>
                              </Radio.Group>
                            </Form.Item>
                              <br/>
                            </Fragment>
                          }

                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{
                              name: `${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '过压值(Mpa)' : '过高(m)'}`,
                              key: 'over'
                            }, {
                              name: `${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '欠压值(Mpa)' : '过低(m)'}`,
                              key: 'under',
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>
                                  {index2 === 2 && <br/>}
                                </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) && Boolean(this.state.hardware_configs.sensor[index].alarm) &&
                            [{
                              name: '报警间隔(秒)',
                              key: 'alarm_upload_interval',
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>

                                </Fragment>;

                            })
                          }


                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'数字输入1'} style={{background: '#fafafa'}}>
                    {
                      !(this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[0] && this.state.hardware_configs.digital_input[0].enable) &&
                      <Button type={'primary'} onClick={()=>{
                        this.state.hardware_configs.digital_input[0].enable = 1;
                        this.state.hardware_configs.digital_input[0].alias = '井盖传感器';
                        this.state.hardware_configs.digital_input[0].type = 'DigitalInput003';
                        this.state.hardware_configs.digital_input[0].alarm = 1;
                        this.state.hardware_configs.digital_input[0].normal_upload_interval = 600;
                        this.state.hardware_configs.digital_input[0].alarm_upload_interval = 30;
                        this.setState({
                          hardware_configs:this.state.hardware_configs
                        })
                      }}>添加井盖</Button>

                    }
                    {
                      [{name: '数字输入1'}, {name: '数字输入2'}].map((item, index) => {
                        if (!(this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index].enable)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          <Fragment>

                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].enable) &&
                              [{name: '别名', key: 'alias'}].map((item2, index2) => {
                                return <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >

                              <span>
                                {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                              </span>
                                  </Form.Item>

                                  <br/>

                                </Fragment>;

                              })}

                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) &&
                              [{name: '正常状态数据上传间隔(秒)', key: 'normal_upload_interval'}].map((item2, index2) => {
                                return (this.state.hardware_configs.digital_input[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                  <Fragment key={index2}>
                                    <Form.Item

                                      label={item2.name}
                                    >
                                      <InputNumber
                                        value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                                        onChange={(e) => {
                                          if (!this.state.hardware_configs.digital_input) {
                                            this.state.hardware_configs.digital_input = [];
                                          }
                                          if (this.state.hardware_configs.digital_input.length < 2) {
                                            if (this.state.hardware_configs.digital_input[index]) {
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            } else {
                                              this.state.hardware_configs.digital_input[index] = {};
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            }
                                          } else {
                                            this.state.hardware_configs.digital_input.splice(index, 1, {
                                              ...this.state.hardware_configs.digital_input[index],
                                              [item2.key]: e,
                                            });
                                          }


                                          this.changeConfig({digital_input: this.state.hardware_configs.digital_input});
                                        }}
                                      />
                                    </Form.Item>
                                    <br/>
                                  </Fragment>;

                              })
                            }
                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) &&
                              <Fragment><Form.Item
                                label="是否预警"
                              >
                                <Radio.Group onChange={(e) => {
                                  if (!this.state.hardware_configs.digital_input) {
                                    this.state.hardware_configs.digital_input = [];
                                  }
                                  if (this.state.hardware_configs.digital_input.length < 2) {
                                    if (this.state.hardware_configs.digital_input[index]) {
                                      this.state.hardware_configs.digital_input[index].alarm = e.target.value;
                                    } else {
                                      this.state.hardware_configs.digital_input[index] = {};
                                      this.state.hardware_configs.digital_input[index].alarm = e.target.value;
                                    }
                                  } else {
                                    this.state.hardware_configs.digital_input.splice(index, 1, {
                                      ...this.state.hardware_configs.digital_input[index],
                                      alarm: e.target.value,
                                    });
                                  }
                                  this.changeConfig({digital_input: this.state.hardware_configs.digital_input});
                                }}
                                             value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index].alarm}>
                                  <Radio value={1}>报警</Radio>
                                  <Radio value={0}>不报警</Radio>
                                </Radio.Group>
                              </Form.Item>
                                <br/>
                              </Fragment>
                            }
                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) && Boolean(this.state.hardware_configs.digital_input[index].alarm) &&
                              [{
                                name: '报警状态数据上传间隔(秒)',
                                key: 'alarm_upload_interval',
                              }].map((item2, index2) => {
                                return (this.state.hardware_configs.digital_input[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                  <Fragment key={index2}>
                                    <Form.Item

                                      label={item2.name}
                                    >
                                      <InputNumber
                                        value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                                        onChange={(e) => {
                                          if (!this.state.hardware_configs.digital_input) {
                                            this.state.hardware_configs.digital_input = [];
                                          }
                                          if (this.state.hardware_configs.digital_input.length < 2) {
                                            if (this.state.hardware_configs.digital_input[index]) {
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            } else {
                                              this.state.hardware_configs.digital_input[index] = {};
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            }
                                          } else {
                                            this.state.hardware_configs.digital_input.splice(index, 1, {
                                              ...this.state.hardware_configs.digital_input[index],
                                              [item2.key]: e,
                                            });
                                          }


                                          this.changeConfig({digital_input: this.state.hardware_configs.digital_input});
                                        }}
                                      />
                                    </Form.Item>

                                  </Fragment>;

                              })
                            }


                          </Fragment>


                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>


              </Form>
            }
            {
              Number(this.state.templateId) === 10 &&
              <Form layout="inline" style={{paddingBottom: '50px'}}>
                <div className={styles.box_item} style={{paddingTop: '12px'}}>
                  <Tabs size='small' defaultActiveKey={'device'} style={{background: '#fafafa'}}>
                    <TabPane tab={'设备信息'} key={'device'}>

                      <Form.Item
                        label="数据上传间隔(分钟)"
                      >
                        <InputNumber
                          value={this.state.hardware_configs.device && this.state.hardware_configs.device[0].upload_interval}
                          onChange={(e) => {
                            if (!this.state.hardware_configs.device) {
                              this.state.hardware_configs.device = [];
                            }
                            if (this.state.hardware_configs.device.length < 1) {
                              this.state.hardware_configs.device[0] = {};
                              this.state.hardware_configs.device[0].upload_interval = e;
                            } else {
                              this.state.hardware_configs.device.splice(0, 1, {
                                ...this.state.hardware_configs.device[0],
                                upload_interval: e,
                              });
                            }
                            this.changeConfig({device: this.state.hardware_configs.device});
                          }}
                        />
                      </Form.Item>
                      <Form.Item
                        label="管径"
                      >
                        <Input
                          addonBefore="DN"
                          style={{width: '120px'}}
                          value={this.state.hardware_configs.customize && this.state.hardware_configs.customize.caliber}
                          onChange={(e) => {
                            if (!this.state.hardware_configs.customize) {
                              this.state.hardware_configs.customize = {}
                            }
                            this.state.hardware_configs.customize = {
                              ...this.state.hardware_configs.customize,
                              caliber: e.target.value
                            }
                            // console.log('this.state.hardware_configs.customize', this.state.hardware_configs.customize)
                            this.changeConfig({customize: this.state.hardware_configs.customize})
                          }}
                        />
                      </Form.Item>
                    </TabPane>
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'Modbus1'} style={{background: '#fafafa'}}>
                    {
                      [{name: 'Modbus1'}].map((item, index) => {
                        if (!(this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index].type)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          <Fragment><Form.Item
                            label='设备类型'>

                      <span>
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},
                              {key: 'DOUBLE-VALVE-PLC', name: '双阀PLC'},
                              {key: 'CHEMITEC-50-SERIES', name: '水质检测'},
                              {key: 'Modbus010', name: '电磁计量器'},
                              {key: 'Modbus011', name: 'Modbus011'},
                              {key: 'Modbus012', name: 'Modbus012'},
                              {key: 'Modbus016', name: 'Modbus016'},
                              {
                                key: 0,
                                name: '无',
                              }], o => o.key === this.state.hardware_configs.modbus_03[index].type) &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},
                              {key: 'DOUBLE-VALVE-PLC', name: '双阀PLC'},
                              {key: 'CHEMITEC-50-SERIES', name: '水质检测'},
                              {key: 'Modbus010', name: '电磁计量器'},
                              {key: 'Modbus011', name: 'Modbus011'},
                              {key: 'Modbus012', name: 'Modbus012'},
                              {key: 'Modbus016', name: 'Modbus016'},
                              {
                                key: 0,
                                name: '无',
                              }], o => o.key === this.state.hardware_configs.modbus_03[index].type).name}
                        </span>
                          </Form.Item>
                          </Fragment>
                          <br/>
                          {
                            this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '别名', key: 'alias'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >

                            <span>
                              {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                            </span>
                                </Form.Item>

                                <br/>

                              </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '数据上传间隔(秒)', key: 'upload_interval'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >
                                  <InputNumber
                                    value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    onChange={(e) => {
                                      if (!this.state.hardware_configs.modbus_03) {
                                        this.state.hardware_configs.modbus_03 = [];
                                      }
                                      if (this.state.hardware_configs.modbus_03.length < 2) {
                                        if (this.state.hardware_configs.modbus_03[index]) {
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        } else {
                                          this.state.hardware_configs.modbus_03[index] = {};
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        }
                                      } else {
                                        this.state.hardware_configs.modbus_03.splice(index, 1, {
                                          ...this.state.hardware_configs.modbus_03[index],
                                          [item2.key]: e,
                                        });
                                      }


                                      this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                    }}
                                  />
                                </Form.Item>
                                <br/>
                              </Fragment>;

                            })
                          }

                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '最低瞬时流量报警值', key: 'min_instantaneous_flow'}, {
                              name: '最高瞬时流量报警值',
                              key: 'max_instantaneous_flow'
                            }].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item
                                  help={'填数字或者"-"，值为"-"时关闭报警'}
                                  label={item2.name}
                                  style={{marginBottom: '0'}}
                                >
                                  <Input
                                    value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    onChange={(e) => {
                                      if (!this.state.hardware_configs.modbus_03) {
                                        this.state.hardware_configs.modbus_03 = [];
                                      }
                                      if (this.state.hardware_configs.modbus_03.length < 2) {
                                        if (this.state.hardware_configs.modbus_03[index]) {
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e.target.value;
                                        } else {
                                          this.state.hardware_configs.modbus_03[index] = {};
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e.target.value;
                                        }
                                      } else {
                                        this.state.hardware_configs.modbus_03.splice(index, 1, {
                                          ...this.state.hardware_configs.modbus_03[index],
                                          [item2.key]: e.target.value,
                                        });
                                      }


                                      this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                    }}
                                  />
                                </Form.Item>
                              </Fragment>;

                            })
                          }

                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
              </Form>
            }
            {
              Number(this.state.templateId) === 11 &&
              <Form layout="inline" style={{paddingBottom: '50px'}}>
                <div className={styles.box_item} style={{paddingTop: '12px'}}>
                  <Tabs size='small' defaultActiveKey={'device'} style={{background: '#fafafa'}}>
                    <TabPane tab={'设备信息'} key={'device'}>

                      <Form.Item
                        label="数据上传间隔(分钟)"
                      >
                        <InputNumber
                          value={this.state.hardware_configs.device && this.state.hardware_configs.device[0].upload_interval}
                          onChange={(e) => {
                            if (!this.state.hardware_configs.device) {
                              this.state.hardware_configs.device = [];
                            }
                            if (this.state.hardware_configs.device.length < 1) {
                              this.state.hardware_configs.device[0] = {};
                              this.state.hardware_configs.device[0].upload_interval = e;
                            } else {
                              this.state.hardware_configs.device.splice(0, 1, {
                                ...this.state.hardware_configs.device[0],
                                upload_interval: e,
                              });
                            }
                            this.changeConfig({device: this.state.hardware_configs.device});
                          }}
                        />
                      </Form.Item>
                    </TabPane>
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'传感器1'} style={{background: '#fafafa'}}>
                    {
                      [{name: '传感器1'}, {name: '传感器2'}, {name: '传感器3'}, {name: '传感器4'}].map((item, index) => {

                        if (!(this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index].type)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          {
                            this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{name: '别名', key: 'alias'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item
                                  label={item2.name}>

                                <span>
                                 {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                </span>
                                </Form.Item>
                                <br/>
                              </Fragment>;

                            })
                          }


                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{name: '上传间隔(秒)', key: 'normal_upload_interval'}, {
                              name: `波动值(${this.state.hardware_configs.sensor[index].type === 'sensor001' ? 'Mpa' : 'm'})`,
                              key: 'fluctuation_value',
                            }, {
                              name: `满量程${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '(Mpa)' : '(m)'}`,
                              key: 'range_max'
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>

                                  <br/>

                                </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            <Fragment><Form.Item
                              label="是否预警"
                            >
                              <Radio.Group
                                onChange={(e) => {
                                  if (!this.state.hardware_configs.sensor) {
                                    this.state.hardware_configs.sensor = [];
                                  }
                                  if (this.state.hardware_configs.sensor.length < 4) {
                                    if (this.state.hardware_configs.sensor[index]) {
                                      this.state.hardware_configs.sensor[index].alarm = e.target.value;
                                    } else {
                                      this.state.hardware_configs.sensor[index] = {};
                                      this.state.hardware_configs.sensor[index].alarm = e.target.value;
                                    }
                                  } else {
                                    this.state.hardware_configs.sensor.splice(index, 1, {
                                      ...this.state.hardware_configs.sensor[index],
                                      alarm: e.target.value,
                                    });
                                  }
                                  this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                }}
                                value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index].alarm}>
                                <Radio value={1}>报警</Radio>
                                <Radio value={0}>不报警</Radio>
                              </Radio.Group>
                            </Form.Item>
                              <br/>
                            </Fragment>
                          }

                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{
                              name: `${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '过压值(Mpa)' : '过高(m)'}`,
                              key: 'over'
                            }, {
                              name: `${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '欠压值(Mpa)' : '过低(m)'}`,
                              key: 'under',
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>
                                  {index2 === 2 && <br/>}
                                </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) && Boolean(this.state.hardware_configs.sensor[index].alarm) &&
                            [{
                              name: '报警间隔(秒)',
                              key: 'alarm_upload_interval',
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>

                                </Fragment>;

                            })
                          }


                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'Modbus1'} style={{background: '#fafafa'}}>
                    {
                      [{name: 'Modbus1'}].map((item, index) => {
                        if (!(this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index].type)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          <Fragment><Form.Item
                            label='设备类型'>

                      <span>
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},
                              {key: 'DOUBLE-VALVE-PLC', name: '双阀PLC'},
                              {key: 'CHEMITEC-50-SERIES', name: '水质检测'},
                              {key: 'Modbus010', name: '电磁计量器'},
                              {key: 'Modbus011', name: 'Modbus011'},
                              {key: 'Modbus012', name: 'Modbus012'},
                              {key: 'Modbus016', name: 'Modbus016'},
                              {key: 'Modbus017', name: 'Modbus017'},
                              {
                                key: 0,
                                name: '无',
                              }], o => o.key === this.state.hardware_configs.modbus_03[index].type) &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},
                              {key: 'DOUBLE-VALVE-PLC', name: '双阀PLC'},
                              {key: 'CHEMITEC-50-SERIES', name: '水质检测'},
                              {key: 'Modbus010', name: '电磁计量器'},
                              {key: 'Modbus011', name: 'Modbus011'},
                              {key: 'Modbus012', name: 'Modbus012'},
                              {key: 'Modbus016', name: 'Modbus016'},
                              {key: 'Modbus017', name: 'Modbus017'},
                              {
                                key: 0,
                                name: '无',
                              }], o => o.key === this.state.hardware_configs.modbus_03[index].type).name}
                        </span>
                          </Form.Item>
                          </Fragment>
                          <br/>
                          {
                            this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '别名', key: 'alias'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >

                            <span>
                              {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                            </span>
                                </Form.Item>

                                <br/>

                              </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '数据上传间隔(秒)', key: 'upload_interval'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >
                                  <InputNumber
                                    value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    onChange={(e) => {
                                      if (!this.state.hardware_configs.modbus_03) {
                                        this.state.hardware_configs.modbus_03 = [];
                                      }
                                      if (this.state.hardware_configs.modbus_03.length < 2) {
                                        if (this.state.hardware_configs.modbus_03[index]) {
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        } else {
                                          this.state.hardware_configs.modbus_03[index] = {};
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        }
                                      } else {
                                        this.state.hardware_configs.modbus_03.splice(index, 1, {
                                          ...this.state.hardware_configs.modbus_03[index],
                                          [item2.key]: e,
                                        });
                                      }


                                      this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                    }}
                                  />
                                </Form.Item>
                                <br/>
                              </Fragment>;

                            })
                          }

                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '最低瞬时流量报警值', key: 'min_instantaneous_flow'}, {
                              name: '最高瞬时流量报警值',
                              key: 'max_instantaneous_flow'
                            }].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item
                                  help={'填数字或者"-"，值为"-"时关闭报警'}
                                  label={item2.name}
                                  style={{marginBottom: '0'}}
                                >
                                  <Input
                                    value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    onChange={(e) => {
                                      if (!this.state.hardware_configs.modbus_03) {
                                        this.state.hardware_configs.modbus_03 = [];
                                      }
                                      if (this.state.hardware_configs.modbus_03.length < 2) {
                                        if (this.state.hardware_configs.modbus_03[index]) {
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e.target.value;
                                        } else {
                                          this.state.hardware_configs.modbus_03[index] = {};
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e.target.value;
                                        }
                                      } else {
                                        this.state.hardware_configs.modbus_03.splice(index, 1, {
                                          ...this.state.hardware_configs.modbus_03[index],
                                          [item2.key]: e.target.value,
                                        });
                                      }


                                      this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                    }}
                                  />
                                </Form.Item>
                              </Fragment>;

                            })
                          }

                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
              </Form>
            }
            {
              (Number(this.state.templateId) === 12 || Number(this.state.templateId) === 22) &&
              <Form layout="inline" style={{paddingBottom: '50px'}}>
                <div className={styles.box_item} style={{paddingTop: '12px'}}>
                  <Tabs size='small' defaultActiveKey={'device'} style={{background: '#fafafa'}}>
                    <TabPane tab={'设备信息'} key={'device'}>

                      <Form.Item
                        label="数据上传间隔(分钟)"
                      >
                        <InputNumber
                          value={this.state.hardware_configs.device && this.state.hardware_configs.device[0].upload_interval}
                          onChange={(e) => {
                            if (!this.state.hardware_configs.device) {
                              this.state.hardware_configs.device = [];
                            }
                            if (this.state.hardware_configs.device.length < 1) {
                              this.state.hardware_configs.device[0] = {};
                              this.state.hardware_configs.device[0].upload_interval = e;
                            } else {
                              this.state.hardware_configs.device.splice(0, 1, {
                                ...this.state.hardware_configs.device[0],
                                upload_interval: e,
                              });
                            }
                            this.changeConfig({device: this.state.hardware_configs.device});
                          }}
                        />
                      </Form.Item>
                    </TabPane>
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'传感器1'} style={{background: '#fafafa'}}>
                    {
                      [{name: '传感器1'}, {name: '传感器2'}, {name: '传感器3'}, {name: '传感器4'}].map((item, index) => {

                        if (!(this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index].type)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          {
                            this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{name: '别名', key: 'alias'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item
                                  label={item2.name}>

                                <span>
                                 {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                </span>
                                </Form.Item>
                                <br/>
                              </Fragment>;

                            })
                          }


                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{name: '上传间隔(秒)', key: 'normal_upload_interval'}, {
                              name: `波动值(${this.state.hardware_configs.sensor[index].type === 'sensor001' ? 'Mpa' : 'm'})`,
                              key: 'fluctuation_value',
                            }, {
                              name: `满量程${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '(Mpa)' : '(m)'}`,
                              key: 'range_max'
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>

                                  <br/>

                                </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            <Fragment><Form.Item
                              label="是否预警"
                            >
                              <Radio.Group
                                onChange={(e) => {
                                  if (!this.state.hardware_configs.sensor) {
                                    this.state.hardware_configs.sensor = [];
                                  }
                                  if (this.state.hardware_configs.sensor.length < 4) {
                                    if (this.state.hardware_configs.sensor[index]) {
                                      this.state.hardware_configs.sensor[index].alarm = e.target.value;
                                    } else {
                                      this.state.hardware_configs.sensor[index] = {};
                                      this.state.hardware_configs.sensor[index].alarm = e.target.value;
                                    }
                                  } else {
                                    this.state.hardware_configs.sensor.splice(index, 1, {
                                      ...this.state.hardware_configs.sensor[index],
                                      alarm: e.target.value,
                                    });
                                  }
                                  this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                }}
                                value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index].alarm}>
                                <Radio value={1}>报警</Radio>
                                <Radio value={0}>不报警</Radio>
                              </Radio.Group>
                            </Form.Item>
                              <br/>
                            </Fragment>
                          }

                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{
                              name: `${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '过压值(Mpa)' : '过高(m)'}`,
                              key: 'over'
                            }, {
                              name: `${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '欠压值(Mpa)' : '过低(m)'}`,
                              key: 'under',
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>
                                  {index2 === 2 && <br/>}
                                </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) && Boolean(this.state.hardware_configs.sensor[index].alarm) &&
                            [{
                              name: '报警间隔(秒)',
                              key: 'alarm_upload_interval',
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>

                                </Fragment>;

                            })
                          }


                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'Modbus1'} style={{background: '#fafafa'}}>
                    {
                      [{name: 'Modbus1'}, {name: 'Modbus2'}].map((item, index) => {
                        if (!(this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index].type)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          <Fragment><Form.Item
                            label='设备类型'>

                      <span>
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},
                              {key: 'DOUBLE-VALVE-PLC', name: '双阀PLC'},
                              {key: 'Modbus018', name: '液位探测器Modbus'},
                              {key: 'Modbus015_1', name: 'Modbus015_1'},
                              {
                                key: 0,
                                name: '无',
                              }], o => o.key === this.state.hardware_configs.modbus_03[index].type) &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},
                              {key: 'DOUBLE-VALVE-PLC', name: '双阀PLC'},
                              {key: 'Modbus018', name: '液位探测器Modbus'},
                              {key: 'Modbus015_1', name: 'Modbus015_1'},
                              {
                                key: 0,
                                name: '无',
                              }], o => o.key === this.state.hardware_configs.modbus_03[index].type).name}
                        </span>
                          </Form.Item>
                          </Fragment>
                          <br/>
                          {
                            this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '别名', key: 'alias'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >

                            <span>
                              {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                            </span>
                                </Form.Item>

                                <br/>

                              </Fragment>;

                            })
                          }


                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) && this.state.hardware_configs.modbus_03[index].type === 'Modbus018' &&
                            [{
                              name: '报警水位(米)',
                              key: 'alarm_water_level'
                            }].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >
                                  <InputNumber
                                    value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    onChange={(e) => {
                                      if (!this.state.hardware_configs.modbus_03) {
                                        this.state.hardware_configs.modbus_03 = [];
                                      }
                                      if (this.state.hardware_configs.modbus_03.length < 2) {
                                        if (this.state.hardware_configs.modbus_03[index]) {
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        } else {
                                          this.state.hardware_configs.modbus_03[index] = {};
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        }
                                      } else {
                                        this.state.hardware_configs.modbus_03.splice(index, 1, {
                                          ...this.state.hardware_configs.modbus_03[index],
                                          [item2.key]: e,
                                        });
                                      }


                                      this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                    }}
                                  />
                                </Form.Item>
                              </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            this.state.hardware_configs.modbus_03[index].type === 'Modbus015_1' &&
                            <Fragment>
                              {
                                [{
                                  name: '蝶阀1动作',
                                  key: 'butterfly_valve1_status',
                                }, {
                                  name: '蝶阀2动作',
                                  key: 'butterfly_valve2_status',
                                }, {
                                  name: '蝶阀3动作',
                                  key: 'butterfly_valve3_status',
                                }, {
                                  name: '蝶阀4动作',
                                  key: 'butterfly_valve4_status',
                                }].map((item2, index2) => {
                                  return <Form.Item

                                    key={index2}
                                    label={item2.name}
                                  >
                                    <Select
                                      style={{width: '80px'}}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.modbus_03) {
                                          this.state.hardware_configs.modbus_03 = [];
                                        }
                                        if (this.state.hardware_configs.modbus_03.length < 4) {
                                          if (this.state.hardware_configs.modbus_03[index]) {
                                            this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.modbus_03[index] = {};
                                            this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.modbus_03.splice(index, 1, {
                                            ...this.state.hardware_configs.modbus_03[index],
                                            [item2.key]: e,
                                          });
                                        }
                                        this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                      }}

                                      value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    >
                                      {[{key: 1, name: '开'}, {key: 2, name: '停'}, {
                                        key: 4,
                                        name: '关',
                                      }].map((item, key) => {
                                        return (
                                          <Option key={key}
                                                  value={item.key}>{item.name}</Option>
                                        );
                                      })}
                                    </Select>
                                  </Form.Item>;

                                })

                              }
                            </Fragment>
                          }

                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '从机地址', key: 'slave_address'},{name: '数据上传间隔(秒)', key: 'upload_interval'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >
                                  <InputNumber
                                    value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    onChange={(e) => {
                                      if (!this.state.hardware_configs.modbus_03) {
                                        this.state.hardware_configs.modbus_03 = [];
                                      }
                                      if (this.state.hardware_configs.modbus_03.length < 2) {
                                        if (this.state.hardware_configs.modbus_03[index]) {
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        } else {
                                          this.state.hardware_configs.modbus_03[index] = {};
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        }
                                      } else {
                                        this.state.hardware_configs.modbus_03.splice(index, 1, {
                                          ...this.state.hardware_configs.modbus_03[index],
                                          [item2.key]: e,
                                        });
                                      }


                                      this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                    }}
                                  />
                                </Form.Item>
                              </Fragment>;

                            })
                          }

                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'数字输入1'} style={{background: '#fafafa'}}>
                    {
                      !(this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[0] && this.state.hardware_configs.digital_input[0].enable) &&
                      <Button type={'primary'} onClick={()=>{
                        this.state.hardware_configs.digital_input[0].enable = 1;
                        this.state.hardware_configs.digital_input[0].alias = '井盖传感器';
                        this.state.hardware_configs.digital_input[0].type = 'DigitalInput003';
                        this.state.hardware_configs.digital_input[0].alarm = 1;
                        this.state.hardware_configs.digital_input[0].normal_upload_interval = 600;
                        this.state.hardware_configs.digital_input[0].alarm_upload_interval = 30;
                        this.setState({
                          hardware_configs:this.state.hardware_configs
                        })
                      }}>添加井盖</Button>

                    }
                    {
                      [{name: '数字输入1'}, {name: '数字输入2'}].map((item, index) => {
                        if (!(this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index].enable)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          <Fragment>

                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].enable) &&
                              [{name: '别名', key: 'alias'}].map((item2, index2) => {
                                return <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >

                              <span>
                                {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                              </span>
                                  </Form.Item>

                                  <br/>

                                </Fragment>;

                              })}

                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) &&
                              [{name: '正常状态数据上传间隔(秒)', key: 'normal_upload_interval'}].map((item2, index2) => {
                                return (this.state.hardware_configs.digital_input[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                  <Fragment key={index2}>
                                    <Form.Item

                                      label={item2.name}
                                    >
                                      <InputNumber
                                        value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                                        onChange={(e) => {
                                          if (!this.state.hardware_configs.digital_input) {
                                            this.state.hardware_configs.digital_input = [];
                                          }
                                          if (this.state.hardware_configs.digital_input.length < 2) {
                                            if (this.state.hardware_configs.digital_input[index]) {
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            } else {
                                              this.state.hardware_configs.digital_input[index] = {};
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            }
                                          } else {
                                            this.state.hardware_configs.digital_input.splice(index, 1, {
                                              ...this.state.hardware_configs.digital_input[index],
                                              [item2.key]: e,
                                            });
                                          }


                                          this.changeConfig({digital_input: this.state.hardware_configs.digital_input});
                                        }}
                                      />
                                    </Form.Item>
                                    <br/>
                                  </Fragment>;

                              })
                            }
                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) &&
                              <Fragment><Form.Item
                                label="是否预警"
                              >
                                <Radio.Group onChange={(e) => {
                                  if (!this.state.hardware_configs.digital_input) {
                                    this.state.hardware_configs.digital_input = [];
                                  }
                                  if (this.state.hardware_configs.digital_input.length < 2) {
                                    if (this.state.hardware_configs.digital_input[index]) {
                                      this.state.hardware_configs.digital_input[index].alarm = e.target.value;
                                    } else {
                                      this.state.hardware_configs.digital_input[index] = {};
                                      this.state.hardware_configs.digital_input[index].alarm = e.target.value;
                                    }
                                  } else {
                                    this.state.hardware_configs.digital_input.splice(index, 1, {
                                      ...this.state.hardware_configs.digital_input[index],
                                      alarm: e.target.value,
                                    });
                                  }
                                  this.changeConfig({digital_input: this.state.hardware_configs.digital_input});
                                }}
                                             value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index].alarm}>
                                  <Radio value={1}>报警</Radio>
                                  <Radio value={0}>不报警</Radio>
                                </Radio.Group>
                              </Form.Item>
                                <br/>
                              </Fragment>
                            }
                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) && Boolean(this.state.hardware_configs.digital_input[index].alarm) &&
                              [{
                                name: '报警状态数据上传间隔(秒)',
                                key: 'alarm_upload_interval',
                              }].map((item2, index2) => {
                                return (this.state.hardware_configs.digital_input[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                  <Fragment key={index2}>
                                    <Form.Item

                                      label={item2.name}
                                    >
                                      <InputNumber
                                        value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                                        onChange={(e) => {
                                          if (!this.state.hardware_configs.digital_input) {
                                            this.state.hardware_configs.digital_input = [];
                                          }
                                          if (this.state.hardware_configs.digital_input.length < 2) {
                                            if (this.state.hardware_configs.digital_input[index]) {
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            } else {
                                              this.state.hardware_configs.digital_input[index] = {};
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            }
                                          } else {
                                            this.state.hardware_configs.digital_input.splice(index, 1, {
                                              ...this.state.hardware_configs.digital_input[index],
                                              [item2.key]: e,
                                            });
                                          }


                                          this.changeConfig({digital_input: this.state.hardware_configs.digital_input});
                                        }}
                                      />
                                    </Form.Item>

                                  </Fragment>;

                              })
                            }


                          </Fragment>


                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
              </Form>
            }
            {
              (Number(this.state.templateId) === 26) &&
              <Form layout="inline" style={{paddingBottom: '50px'}}>
                <div className={styles.box_item} style={{paddingTop: '12px'}}>
                  <Tabs size='small' defaultActiveKey={'device'} style={{background: '#fafafa'}}>
                    <TabPane tab={'设备信息'} key={'device'}>

                      <Form.Item
                        label="数据上传间隔(分钟)"
                      >
                        <InputNumber
                          value={this.state.hardware_configs.device && this.state.hardware_configs.device[0].upload_interval}
                          onChange={(e) => {
                            if (!this.state.hardware_configs.device) {
                              this.state.hardware_configs.device = [];
                            }
                            if (this.state.hardware_configs.device.length < 1) {
                              this.state.hardware_configs.device[0] = {};
                              this.state.hardware_configs.device[0].upload_interval = e;
                            } else {
                              this.state.hardware_configs.device.splice(0, 1, {
                                ...this.state.hardware_configs.device[0],
                                upload_interval: e,
                              });
                            }
                            this.changeConfig({device: this.state.hardware_configs.device});
                          }}
                        />
                      </Form.Item>
                    </TabPane>
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'传感器1'} style={{background: '#fafafa'}}>
                    {
                      [{name: '传感器1'}, {name: '传感器2'}, {name: '传感器3'}, {name: '传感器4'}].map((item, index) => {

                        if (!(this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index].type)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          {
                            this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{name: '别名', key: 'alias'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item
                                  label={item2.name}>

                                <span>
                                 {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                </span>
                                </Form.Item>
                                <br/>
                              </Fragment>;

                            })
                          }


                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{name: '上传间隔(秒)', key: 'normal_upload_interval'}, {
                              name: `波动值(${this.state.hardware_configs.sensor[index].type === 'sensor001' ? 'Mpa' : 'm'})`,
                              key: 'fluctuation_value',
                            }, {
                              name: `满量程${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '(Mpa)' : '(m)'}`,
                              key: 'range_max'
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>

                                  <br/>

                                </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            <Fragment><Form.Item
                              label="是否预警"
                            >
                              <Radio.Group
                                onChange={(e) => {
                                  if (!this.state.hardware_configs.sensor) {
                                    this.state.hardware_configs.sensor = [];
                                  }
                                  if (this.state.hardware_configs.sensor.length < 4) {
                                    if (this.state.hardware_configs.sensor[index]) {
                                      this.state.hardware_configs.sensor[index].alarm = e.target.value;
                                    } else {
                                      this.state.hardware_configs.sensor[index] = {};
                                      this.state.hardware_configs.sensor[index].alarm = e.target.value;
                                    }
                                  } else {
                                    this.state.hardware_configs.sensor.splice(index, 1, {
                                      ...this.state.hardware_configs.sensor[index],
                                      alarm: e.target.value,
                                    });
                                  }
                                  this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                }}
                                value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index].alarm}>
                                <Radio value={1}>报警</Radio>
                                <Radio value={0}>不报警</Radio>
                              </Radio.Group>
                            </Form.Item>
                              <br/>
                            </Fragment>
                          }

                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{
                              name: `${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '过压值(Mpa)' : '过高(m)'}`,
                              key: 'over'
                            }, {
                              name: `${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '欠压值(Mpa)' : '过低(m)'}`,
                              key: 'under',
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>
                                  {index2 === 2 && <br/>}
                                </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) && Boolean(this.state.hardware_configs.sensor[index].alarm) &&
                            [{
                              name: '报警间隔(秒)',
                              key: 'alarm_upload_interval',
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>

                                </Fragment>;

                            })
                          }


                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'Modbus1'} style={{background: '#fafafa'}}>
                    {
                      [{name: 'Modbus1'}, {name: 'Modbus2'}].map((item, index) => {
                        if (!(this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index].type)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          <Fragment><Form.Item
                            label='设备类型'>

                      <span>
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},
                              {key: 'DOUBLE-VALVE-PLC', name: '双阀PLC'},
                              {key: 'Modbus018', name: '液位探测器Modbus'},
                              {
                                key: 0,
                                name: '无',
                              }], o => o.key === this.state.hardware_configs.modbus_03[index].type) &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},
                              {key: 'DOUBLE-VALVE-PLC', name: '双阀PLC'},
                              {key: 'Modbus018', name: '液位探测器Modbus'},
                              {
                                key: 0,
                                name: '无',
                              }], o => o.key === this.state.hardware_configs.modbus_03[index].type).name}
                        </span>
                          </Form.Item>
                          </Fragment>
                          <br/>
                          {
                            this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '别名', key: 'alias'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >

                            <span>
                              {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                            </span>
                                </Form.Item>

                                <br/>

                              </Fragment>;

                            })
                          }


                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) && this.state.hardware_configs.modbus_03[index].type === 'Modbus018' &&
                            [{name: '数据上传间隔(秒)', key: 'upload_interval'}, {
                              name: '报警水位(米)',
                              key: 'alarm_water_level'
                            }].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >
                                  <InputNumber
                                    value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    onChange={(e) => {
                                      if (!this.state.hardware_configs.modbus_03) {
                                        this.state.hardware_configs.modbus_03 = [];
                                      }
                                      if (this.state.hardware_configs.modbus_03.length < 2) {
                                        if (this.state.hardware_configs.modbus_03[index]) {
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        } else {
                                          this.state.hardware_configs.modbus_03[index] = {};
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        }
                                      } else {
                                        this.state.hardware_configs.modbus_03.splice(index, 1, {
                                          ...this.state.hardware_configs.modbus_03[index],
                                          [item2.key]: e,
                                        });
                                      }


                                      this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                    }}
                                  />
                                </Form.Item>
                              </Fragment>;

                            })
                          }

                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'调节阀1-1'} style={{background: '#fafafa'}}>
                    {
                      [{name: '调节阀1'}, {name: '调节阀2'}].map((item, index) => {
                        if (!(this.state.hardware_configs.control_valve && this.state.hardware_configs.control_valve[index] && this.state.hardware_configs.control_valve[index].enable)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          <Fragment>

                            {this.state.hardware_configs.control_valve && this.state.hardware_configs.control_valve[index] && Boolean(this.state.hardware_configs.control_valve[index].enable) &&
                              [{name: '别名', key: 'alias'}].map((item2, index2) => {
                                return <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >

                              <span>
                                {this.state.hardware_configs.control_valve && this.state.hardware_configs.control_valve[index] && this.state.hardware_configs.control_valve[index][item2.key]}
                              </span>
                                  </Form.Item>

                                  <br/>

                                </Fragment>;

                              })
                            }
                          </Fragment>

                          {this.state.hardware_configs.control_valve && this.state.hardware_configs.control_valve[index] && Boolean(this.state.hardware_configs.control_valve[index].enable) &&
                            <Fragment><Form.Item
                              label="设备编号"
                            >

                              <Input
                                value={this.state.hardware_configs.control_valve && this.state.hardware_configs.control_valve[index] && this.state.hardware_configs.control_valve[index].device_number}
                                onChange={(e) => {
                                  if (!this.state.hardware_configs.control_valve) {
                                    this.state.hardware_configs.control_valve = [];
                                  }
                                  if (this.state.hardware_configs.control_valve.length < 2) {
                                    if (this.state.hardware_configs.control_valve[index]) {
                                      this.state.hardware_configs.control_valve[index].device_number = e.target.value;
                                    } else {
                                      this.state.hardware_configs.control_valve[index] = {};
                                      this.state.hardware_configs.control_valve[index].device_number = e.target.value;
                                    }
                                  } else {
                                    this.state.hardware_configs.control_valve.splice(index, 1, {
                                      ...this.state.hardware_configs.control_valve[index],
                                      device_number: e.target.value,
                                    });
                                  }


                                  this.changeConfig({control_valve: this.state.hardware_configs.control_valve});
                                }}
                              />
                            </Form.Item></Fragment>
                          }
                          {
                            this.props.editRecord &&
                            <Fragment>
                              <Button type={'primary'} onClick={() => {
                                this.setState({
                                  device_number: this.state.hardware_configs.control_valve[index].device_number,
                                  config_index: index,
                                  configModal: true,
                                })
                              }}>调节阀配置</Button>
                            </Fragment>
                          }

                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'数字输入1'} style={{background: '#fafafa'}}>
                    {
                      !(this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[0] && this.state.hardware_configs.digital_input[0].enable) &&
                      <Button type={'primary'} onClick={()=>{
                        this.state.hardware_configs.digital_input[0].enable = 1;
                        this.state.hardware_configs.digital_input[0].alias = '井盖传感器';
                        this.state.hardware_configs.digital_input[0].type = 'DigitalInput002';
                        this.state.hardware_configs.digital_input[0].alarm = 1;
                        this.state.hardware_configs.digital_input[0].normal_upload_interval = 600;
                        this.state.hardware_configs.digital_input[0].alarm_upload_interval = 30;
                        this.setState({
                          hardware_configs:this.state.hardware_configs
                        })
                      }}>添加井盖</Button>

                    }
                    {
                      [{name: '数字输入1'}, {name: '数字输入2'}].map((item, index) => {
                        if (!(this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index].enable)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          <Fragment>

                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].enable) &&
                              [{name: '别名', key: 'alias'}].map((item2, index2) => {
                                return <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >

                              <span>
                                {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                              </span>
                                  </Form.Item>

                                  <br/>

                                </Fragment>;

                              })}

                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) &&
                              [{name: '正常状态数据上传间隔(秒)', key: 'normal_upload_interval'}].map((item2, index2) => {
                                return (this.state.hardware_configs.digital_input[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                  <Fragment key={index2}>
                                    <Form.Item

                                      label={item2.name}
                                    >
                                      <InputNumber
                                        value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                                        onChange={(e) => {
                                          if (!this.state.hardware_configs.digital_input) {
                                            this.state.hardware_configs.digital_input = [];
                                          }
                                          if (this.state.hardware_configs.digital_input.length < 2) {
                                            if (this.state.hardware_configs.digital_input[index]) {
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            } else {
                                              this.state.hardware_configs.digital_input[index] = {};
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            }
                                          } else {
                                            this.state.hardware_configs.digital_input.splice(index, 1, {
                                              ...this.state.hardware_configs.digital_input[index],
                                              [item2.key]: e,
                                            });
                                          }


                                          this.changeConfig({digital_input: this.state.hardware_configs.digital_input});
                                        }}
                                      />
                                    </Form.Item>
                                    <br/>
                                  </Fragment>;

                              })
                            }
                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) &&
                              <Fragment><Form.Item
                                label="是否预警"
                              >
                                <Radio.Group onChange={(e) => {
                                  if (!this.state.hardware_configs.digital_input) {
                                    this.state.hardware_configs.digital_input = [];
                                  }
                                  if (this.state.hardware_configs.digital_input.length < 2) {
                                    if (this.state.hardware_configs.digital_input[index]) {
                                      this.state.hardware_configs.digital_input[index].alarm = e.target.value;
                                    } else {
                                      this.state.hardware_configs.digital_input[index] = {};
                                      this.state.hardware_configs.digital_input[index].alarm = e.target.value;
                                    }
                                  } else {
                                    this.state.hardware_configs.digital_input.splice(index, 1, {
                                      ...this.state.hardware_configs.digital_input[index],
                                      alarm: e.target.value,
                                    });
                                  }
                                  this.changeConfig({digital_input: this.state.hardware_configs.digital_input});
                                }}
                                             value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index].alarm}>
                                  <Radio value={1}>报警</Radio>
                                  <Radio value={0}>不报警</Radio>
                                </Radio.Group>
                              </Form.Item>
                                <br/>
                              </Fragment>
                            }
                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) && Boolean(this.state.hardware_configs.digital_input[index].alarm) &&
                              [{
                                name: '报警状态数据上传间隔(秒)',
                                key: 'alarm_upload_interval',
                              }].map((item2, index2) => {
                                return (this.state.hardware_configs.digital_input[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                  <Fragment key={index2}>
                                    <Form.Item

                                      label={item2.name}
                                    >
                                      <InputNumber
                                        value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                                        onChange={(e) => {
                                          if (!this.state.hardware_configs.digital_input) {
                                            this.state.hardware_configs.digital_input = [];
                                          }
                                          if (this.state.hardware_configs.digital_input.length < 2) {
                                            if (this.state.hardware_configs.digital_input[index]) {
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            } else {
                                              this.state.hardware_configs.digital_input[index] = {};
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            }
                                          } else {
                                            this.state.hardware_configs.digital_input.splice(index, 1, {
                                              ...this.state.hardware_configs.digital_input[index],
                                              [item2.key]: e,
                                            });
                                          }


                                          this.changeConfig({digital_input: this.state.hardware_configs.digital_input});
                                        }}
                                      />
                                    </Form.Item>

                                  </Fragment>;

                              })
                            }


                          </Fragment>


                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
              </Form>
            }
            {
              (Number(this.state.templateId) === 35) &&
              <Form layout="inline" style={{paddingBottom: '50px'}}>
                <div className={styles.box_item} style={{paddingTop: '12px'}}>
                  <Tabs size='small' defaultActiveKey={'device'} style={{background: '#fafafa'}}>
                    <TabPane tab={'设备信息'} key={'device'}>

                      <Form.Item
                        label="数据上传间隔(分钟)"
                      >
                        <InputNumber
                          value={this.state.hardware_configs.device && this.state.hardware_configs.device[0].upload_interval}
                          onChange={(e) => {
                            if (!this.state.hardware_configs.device) {
                              this.state.hardware_configs.device = [];
                            }
                            if (this.state.hardware_configs.device.length < 1) {
                              this.state.hardware_configs.device[0] = {};
                              this.state.hardware_configs.device[0].upload_interval = e;
                            } else {
                              this.state.hardware_configs.device.splice(0, 1, {
                                ...this.state.hardware_configs.device[0],
                                upload_interval: e,
                              });
                            }
                            this.changeConfig({device: this.state.hardware_configs.device});
                          }}
                        />
                      </Form.Item>
                    </TabPane>
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'传感器1'} style={{background: '#fafafa'}}>
                    {
                      [{name: '传感器1'}, {name: '传感器2'}, {name: '传感器3'}, {name: '传感器4'}].map((item, index) => {

                        if (!(this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index].type)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          {
                            this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{name: '别名', key: 'alias'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item
                                  label={item2.name}>

                                <span>
                                 {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                </span>
                                </Form.Item>
                                <br/>
                              </Fragment>;

                            })
                          }


                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{name: '上传间隔(秒)', key: 'normal_upload_interval'}, {
                              name: `波动值(${this.state.hardware_configs.sensor[index].type === 'sensor001' ? 'Mpa' : 'm'})`,
                              key: 'fluctuation_value',
                            }, {
                              name: `满量程${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '(Mpa)' : '(m)'}`,
                              key: 'range_max'
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>

                                  <br/>

                                </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            <Fragment><Form.Item
                              label="是否预警"
                            >
                              <Radio.Group
                                onChange={(e) => {
                                  if (!this.state.hardware_configs.sensor) {
                                    this.state.hardware_configs.sensor = [];
                                  }
                                  if (this.state.hardware_configs.sensor.length < 4) {
                                    if (this.state.hardware_configs.sensor[index]) {
                                      this.state.hardware_configs.sensor[index].alarm = e.target.value;
                                    } else {
                                      this.state.hardware_configs.sensor[index] = {};
                                      this.state.hardware_configs.sensor[index].alarm = e.target.value;
                                    }
                                  } else {
                                    this.state.hardware_configs.sensor.splice(index, 1, {
                                      ...this.state.hardware_configs.sensor[index],
                                      alarm: e.target.value,
                                    });
                                  }
                                  this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                }}
                                value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index].alarm}>
                                <Radio value={1}>报警</Radio>
                                <Radio value={0}>不报警</Radio>
                              </Radio.Group>
                            </Form.Item>
                              <br/>
                            </Fragment>
                          }

                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{
                              name: `${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '过压值(Mpa)' : '过高(m)'}`,
                              key: 'over'
                            }, {
                              name: `${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '欠压值(Mpa)' : '过低(m)'}`,
                              key: 'under',
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>
                                  {index2 === 2 && <br/>}
                                </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) && Boolean(this.state.hardware_configs.sensor[index].alarm) &&
                            [{
                              name: '报警间隔(秒)',
                              key: 'alarm_upload_interval',
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>

                                </Fragment>;

                            })
                          }


                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'Modbus1'} style={{background: '#fafafa'}}>
                    {
                      [{name: 'Modbus1'}, {name: 'Modbus2'}, {name: 'Modbus3'}, {name: 'Modbus4'}].map((item, index) => {
                        if (!(this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index].type)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          <Fragment><Form.Item
                            label='设备类型'>

                      <span>
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},
                              {key: 'DOUBLE-VALVE-PLC', name: '双阀PLC'},
                              {key: 'Modbus018', name: '液位探测器Modbus'},
                              {key: 'Modbus015_1', name: 'Modbus015_1'},
                              {key: 'Modbus015_2', name: 'Modbus015_2'},
                              {key: 'Modbus024', name: 'Modbus024'},
                              {
                                key: 0,
                                name: '无',
                              }], o => o.key === this.state.hardware_configs.modbus_03[index].type) &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},
                              {key: 'DOUBLE-VALVE-PLC', name: '双阀PLC'},
                              {key: 'Modbus018', name: '液位探测器Modbus'},
                              {key: 'Modbus015_1', name: 'Modbus015_1'},
                              {key: 'Modbus015_2', name: 'Modbus015_2'},
                              {key: 'Modbus024', name: 'Modbus024'},
                              {
                                key: 0,
                                name: '无',
                              }], o => o.key === this.state.hardware_configs.modbus_03[index].type).name}
                        </span>
                          </Form.Item>
                          </Fragment>
                          <br/>
                          {
                            this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '别名', key: 'alias'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >

                            <span>
                              {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                            </span>
                                </Form.Item>

                                <br/>

                              </Fragment>;

                            })
                          }


                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            this.state.hardware_configs.modbus_03[index].type === 'Modbus018' &&
                            [{name: '报警水位(米)', key: 'alarm_water_level'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >
                                  <InputNumber
                                    value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    onChange={(e) => {
                                      if (!this.state.hardware_configs.modbus_03) {
                                        this.state.hardware_configs.modbus_03 = [];
                                      }
                                      if (this.state.hardware_configs.modbus_03.length < 2) {
                                        if (this.state.hardware_configs.modbus_03[index]) {
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        } else {
                                          this.state.hardware_configs.modbus_03[index] = {};
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        }
                                      } else {
                                        this.state.hardware_configs.modbus_03.splice(index, 1, {
                                          ...this.state.hardware_configs.modbus_03[index],
                                          [item2.key]: e,
                                        });
                                      }


                                      this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                    }}
                                  />
                                </Form.Item>
                              </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            this.state.hardware_configs.modbus_03[index].type === 'Modbus024' &&
                            <Fragment>
                              {
                                [{
                                  name: '蝶阀1动作',
                                  key: 'butterfly_valve1_status',
                                }, {
                                  name: '蝶阀2动作',
                                  key: 'butterfly_valve2_status',
                                }, {
                                  name: '蝶阀3动作',
                                  key: 'butterfly_valve3_status',
                                }, {
                                  name: '蝶阀4动作',
                                  key: 'butterfly_valve4_status',
                                }].map((item2, index2) => {
                                  return <Form.Item

                                    key={index2}
                                    label={item2.name}
                                  >
                                    <Select
                                      style={{width: '80px'}}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.modbus_03) {
                                          this.state.hardware_configs.modbus_03 = [];
                                        }
                                        if (this.state.hardware_configs.modbus_03.length < 4) {
                                          if (this.state.hardware_configs.modbus_03[index]) {
                                            this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.modbus_03[index] = {};
                                            this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.modbus_03.splice(index, 1, {
                                            ...this.state.hardware_configs.modbus_03[index],
                                            [item2.key]: e,
                                          });
                                        }
                                        this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                      }}

                                      value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    >
                                      {[{key: 1, name: '开'}, {key: 2, name: '停'}, {
                                        key: 4,
                                        name: '关',
                                      }].map((item, key) => {
                                        return (
                                          <Option key={key}
                                                  value={item.key}>{item.name}</Option>
                                        );
                                      })}
                                    </Select>
                                  </Form.Item>;

                                })

                              }
                            </Fragment>
                          }

                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '从机地址', key: 'slave_address'}, {
                              name: '数据上传间隔(秒)',
                              key: 'upload_interval'
                            }].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >
                                  <InputNumber
                                    min={0}
                                    value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    onChange={(e) => {
                                      if (!this.state.hardware_configs.modbus_03) {
                                        this.state.hardware_configs.modbus_03 = [];
                                      }
                                      if (this.state.hardware_configs.modbus_03.length < 2) {
                                        if (this.state.hardware_configs.modbus_03[index]) {
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        } else {
                                          this.state.hardware_configs.modbus_03[index] = {};
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        }
                                      } else {
                                        this.state.hardware_configs.modbus_03.splice(index, 1, {
                                          ...this.state.hardware_configs.modbus_03[index],
                                          [item2.key]: e,
                                        });
                                      }


                                      this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                    }}
                                  />
                                </Form.Item>
                              </Fragment>;

                            })
                          }

                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'数字输入1'} style={{background: '#fafafa'}}>
                    {
                      !(this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[0] && this.state.hardware_configs.digital_input[0].enable) &&
                      <Button type={'primary'} onClick={()=>{
                        this.state.hardware_configs.digital_input[0].enable = 1;
                        this.state.hardware_configs.digital_input[0].alias = '井盖传感器';
                        this.state.hardware_configs.digital_input[0].type = 'DigitalInput003';
                        this.state.hardware_configs.digital_input[0].alarm = 1;
                        this.state.hardware_configs.digital_input[0].normal_upload_interval = 600;
                        this.state.hardware_configs.digital_input[0].alarm_upload_interval = 30;
                        this.setState({
                          hardware_configs:this.state.hardware_configs
                        })
                      }}>添加井盖</Button>

                    }
                    {
                      [{name: '数字输入1'}, {name: '数字输入2'}].map((item, index) => {
                        if (!(this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index].enable)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          <Fragment>

                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].enable) &&
                              [{name: '别名', key: 'alias'}].map((item2, index2) => {
                                return <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >

                              <span>
                                {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                              </span>
                                  </Form.Item>

                                  <br/>

                                </Fragment>;

                              })}

                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) &&
                              [{name: '正常状态数据上传间隔(秒)', key: 'normal_upload_interval'}].map((item2, index2) => {
                                return (this.state.hardware_configs.digital_input[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                  <Fragment key={index2}>
                                    <Form.Item

                                      label={item2.name}
                                    >
                                      <InputNumber
                                        value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                                        onChange={(e) => {
                                          if (!this.state.hardware_configs.digital_input) {
                                            this.state.hardware_configs.digital_input = [];
                                          }
                                          if (this.state.hardware_configs.digital_input.length < 2) {
                                            if (this.state.hardware_configs.digital_input[index]) {
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            } else {
                                              this.state.hardware_configs.digital_input[index] = {};
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            }
                                          } else {
                                            this.state.hardware_configs.digital_input.splice(index, 1, {
                                              ...this.state.hardware_configs.digital_input[index],
                                              [item2.key]: e,
                                            });
                                          }


                                          this.changeConfig({digital_input: this.state.hardware_configs.digital_input});
                                        }}
                                      />
                                    </Form.Item>
                                    <br/>
                                  </Fragment>;

                              })
                            }
                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) &&
                              <Fragment><Form.Item
                                label="是否预警"
                              >
                                <Radio.Group onChange={(e) => {
                                  if (!this.state.hardware_configs.digital_input) {
                                    this.state.hardware_configs.digital_input = [];
                                  }
                                  if (this.state.hardware_configs.digital_input.length < 2) {
                                    if (this.state.hardware_configs.digital_input[index]) {
                                      this.state.hardware_configs.digital_input[index].alarm = e.target.value;
                                    } else {
                                      this.state.hardware_configs.digital_input[index] = {};
                                      this.state.hardware_configs.digital_input[index].alarm = e.target.value;
                                    }
                                  } else {
                                    this.state.hardware_configs.digital_input.splice(index, 1, {
                                      ...this.state.hardware_configs.digital_input[index],
                                      alarm: e.target.value,
                                    });
                                  }
                                  this.changeConfig({digital_input: this.state.hardware_configs.digital_input});
                                }}
                                             value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index].alarm}>
                                  <Radio value={1}>报警</Radio>
                                  <Radio value={0}>不报警</Radio>
                                </Radio.Group>
                              </Form.Item>
                                <br/>
                              </Fragment>
                            }
                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) && Boolean(this.state.hardware_configs.digital_input[index].alarm) &&
                              [{
                                name: '报警状态数据上传间隔(秒)',
                                key: 'alarm_upload_interval',
                              }].map((item2, index2) => {
                                return (this.state.hardware_configs.digital_input[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                  <Fragment key={index2}>
                                    <Form.Item

                                      label={item2.name}
                                    >
                                      <InputNumber
                                        value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                                        onChange={(e) => {
                                          if (!this.state.hardware_configs.digital_input) {
                                            this.state.hardware_configs.digital_input = [];
                                          }
                                          if (this.state.hardware_configs.digital_input.length < 2) {
                                            if (this.state.hardware_configs.digital_input[index]) {
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            } else {
                                              this.state.hardware_configs.digital_input[index] = {};
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            }
                                          } else {
                                            this.state.hardware_configs.digital_input.splice(index, 1, {
                                              ...this.state.hardware_configs.digital_input[index],
                                              [item2.key]: e,
                                            });
                                          }


                                          this.changeConfig({digital_input: this.state.hardware_configs.digital_input});
                                        }}
                                      />
                                    </Form.Item>

                                  </Fragment>;

                              })
                            }


                          </Fragment>


                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
              </Form>
            }
            {
              (Number(this.state.templateId) === 36) &&
              <Form layout="inline" style={{paddingBottom: '50px'}}>
                <div className={styles.box_item} style={{paddingTop: '12px'}}>
                  <Tabs size='small' defaultActiveKey={'device'} style={{background: '#fafafa'}}>
                    <TabPane tab={'设备信息'} key={'device'}>

                      <Form.Item
                        label="数据上传间隔(分钟)"
                      >
                        <InputNumber
                          value={this.state.hardware_configs.device && this.state.hardware_configs.device[0].upload_interval}
                          onChange={(e) => {
                            if (!this.state.hardware_configs.device) {
                              this.state.hardware_configs.device = [];
                            }
                            if (this.state.hardware_configs.device.length < 1) {
                              this.state.hardware_configs.device[0] = {};
                              this.state.hardware_configs.device[0].upload_interval = e;
                            } else {
                              this.state.hardware_configs.device.splice(0, 1, {
                                ...this.state.hardware_configs.device[0],
                                upload_interval: e,
                              });
                            }
                            this.changeConfig({device: this.state.hardware_configs.device});
                          }}
                        />
                      </Form.Item>
                    </TabPane>
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'传感器1'} style={{background: '#fafafa'}}>
                    {
                      [{name: '传感器1'}, {name: '传感器2'}, {name: '传感器3'}, {name: '传感器4'}].map((item, index) => {

                        if (!(this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index].type)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          {
                            this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{name: '别名', key: 'alias'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item
                                  label={item2.name}>

                                <span>
                                 {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                </span>
                                </Form.Item>
                                <br/>
                              </Fragment>;

                            })
                          }


                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{name: '上传间隔(秒)', key: 'normal_upload_interval'}, {
                              name: `波动值(${this.state.hardware_configs.sensor[index].type === 'sensor001' ? 'Mpa' : 'm'})`,
                              key: 'fluctuation_value',
                            }, {
                              name: `满量程${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '(Mpa)' : '(m)'}`,
                              key: 'range_max'
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>

                                  <br/>

                                </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            <Fragment><Form.Item
                              label="是否预警"
                            >
                              <Radio.Group
                                onChange={(e) => {
                                  if (!this.state.hardware_configs.sensor) {
                                    this.state.hardware_configs.sensor = [];
                                  }
                                  if (this.state.hardware_configs.sensor.length < 4) {
                                    if (this.state.hardware_configs.sensor[index]) {
                                      this.state.hardware_configs.sensor[index].alarm = e.target.value;
                                    } else {
                                      this.state.hardware_configs.sensor[index] = {};
                                      this.state.hardware_configs.sensor[index].alarm = e.target.value;
                                    }
                                  } else {
                                    this.state.hardware_configs.sensor.splice(index, 1, {
                                      ...this.state.hardware_configs.sensor[index],
                                      alarm: e.target.value,
                                    });
                                  }
                                  this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                }}
                                value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index].alarm}>
                                <Radio value={1}>报警</Radio>
                                <Radio value={0}>不报警</Radio>
                              </Radio.Group>
                            </Form.Item>
                              <br/>
                            </Fragment>
                          }

                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{
                              name: `${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '过压值(Mpa)' : '过高(m)'}`,
                              key: 'over'
                            }, {
                              name: `${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '欠压值(Mpa)' : '过低(m)'}`,
                              key: 'under',
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>
                                  {index2 === 2 && <br/>}
                                </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) && Boolean(this.state.hardware_configs.sensor[index].alarm) &&
                            [{
                              name: '报警间隔(秒)',
                              key: 'alarm_upload_interval',
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>

                                </Fragment>;

                            })
                          }


                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'Modbus1'} style={{background: '#fafafa'}}>
                    {
                      [{name: 'Modbus1'}, {name: 'Modbus2'}, {name: 'Modbus3'}, {name: 'Modbus4'}].map((item, index) => {
                        if (!(this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index].type)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          <Fragment><Form.Item
                            label='设备类型'>

                      <span>
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},
                              {key: 'DOUBLE-VALVE-PLC', name: '双阀PLC'},
                              {key: 'Modbus018', name: '液位探测器Modbus'},
                              {key: 'Modbus015_1', name: 'Modbus015_1'},
                              {key: 'Modbus015_2', name: 'Modbus015_2'},
                              {key: 'Modbus024', name: 'Modbus024'},
                              {
                                key: 0,
                                name: '无',
                              }], o => o.key === this.state.hardware_configs.modbus_03[index].type) &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},
                              {key: 'DOUBLE-VALVE-PLC', name: '双阀PLC'},
                              {key: 'Modbus018', name: '液位探测器Modbus'},
                              {key: 'Modbus015_1', name: 'Modbus015_1'},
                              {key: 'Modbus015_2', name: 'Modbus015_2'},
                              {key: 'Modbus024', name: 'Modbus024'},
                              {
                                key: 0,
                                name: '无',
                              }], o => o.key === this.state.hardware_configs.modbus_03[index].type).name}
                        </span>
                          </Form.Item>
                          </Fragment>
                          <br/>
                          {
                            this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '别名', key: 'alias'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >

                            <span>
                              {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                            </span>
                                </Form.Item>

                                <br/>

                              </Fragment>;

                            })
                          }


                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            this.state.hardware_configs.modbus_03[index].type === 'Modbus018' &&
                            [{name: '报警水位(米)', key: 'alarm_water_level'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >
                                  <InputNumber
                                    value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    onChange={(e) => {
                                      if (!this.state.hardware_configs.modbus_03) {
                                        this.state.hardware_configs.modbus_03 = [];
                                      }
                                      if (this.state.hardware_configs.modbus_03.length < 2) {
                                        if (this.state.hardware_configs.modbus_03[index]) {
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        } else {
                                          this.state.hardware_configs.modbus_03[index] = {};
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        }
                                      } else {
                                        this.state.hardware_configs.modbus_03.splice(index, 1, {
                                          ...this.state.hardware_configs.modbus_03[index],
                                          [item2.key]: e,
                                        });
                                      }


                                      this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                    }}
                                  />
                                </Form.Item>
                              </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            this.state.hardware_configs.modbus_03[index].type === 'Modbus024' &&
                            <Fragment>
                              {
                                [{
                                  name: '蝶阀1动作',
                                  key: 'butterfly_valve1_status',
                                }, {
                                  name: '蝶阀2动作',
                                  key: 'butterfly_valve2_status',
                                }, {
                                  name: '蝶阀3动作',
                                  key: 'butterfly_valve3_status',
                                }, {
                                  name: '蝶阀4动作',
                                  key: 'butterfly_valve4_status',
                                }].map((item2, index2) => {
                                  return <Form.Item

                                    key={index2}
                                    label={item2.name}
                                  >
                                    <Select
                                      style={{width: '80px'}}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.modbus_03) {
                                          this.state.hardware_configs.modbus_03 = [];
                                        }
                                        if (this.state.hardware_configs.modbus_03.length < 4) {
                                          if (this.state.hardware_configs.modbus_03[index]) {
                                            this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.modbus_03[index] = {};
                                            this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.modbus_03.splice(index, 1, {
                                            ...this.state.hardware_configs.modbus_03[index],
                                            [item2.key]: e,
                                          });
                                        }
                                        this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                      }}

                                      value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    >
                                      {[{key: 1, name: '开'}, {key: 2, name: '停'}, {
                                        key: 4,
                                        name: '关',
                                      }].map((item, key) => {
                                        return (
                                          <Option key={key}
                                                  value={item.key}>{item.name}</Option>
                                        );
                                      })}
                                    </Select>
                                  </Form.Item>;

                                })

                              }
                            </Fragment>
                          }

                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '从机地址', key: 'slave_address'}, {
                              name: '数据上传间隔(秒)',
                              key: 'upload_interval'
                            }].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >
                                  <InputNumber
                                    min={0}
                                    value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    onChange={(e) => {
                                      if (!this.state.hardware_configs.modbus_03) {
                                        this.state.hardware_configs.modbus_03 = [];
                                      }
                                      if (this.state.hardware_configs.modbus_03.length < 2) {
                                        if (this.state.hardware_configs.modbus_03[index]) {
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        } else {
                                          this.state.hardware_configs.modbus_03[index] = {};
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        }
                                      } else {
                                        this.state.hardware_configs.modbus_03.splice(index, 1, {
                                          ...this.state.hardware_configs.modbus_03[index],
                                          [item2.key]: e,
                                        });
                                      }


                                      this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                    }}
                                  />
                                </Form.Item>
                              </Fragment>;

                            })
                          }

                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'调节阀1-1'} style={{background: '#fafafa'}}>
                    {
                      [{name: '调节阀1'}, {name: '调节阀2'}].map((item, index) => {
                        if (!(this.state.hardware_configs.control_valve && this.state.hardware_configs.control_valve[index] && this.state.hardware_configs.control_valve[index].enable)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          <Fragment>

                            {this.state.hardware_configs.control_valve && this.state.hardware_configs.control_valve[index] && Boolean(this.state.hardware_configs.control_valve[index].enable) &&
                              [{name: '别名', key: 'alias'}].map((item2, index2) => {
                                return <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >

                              <span>
                                {this.state.hardware_configs.control_valve && this.state.hardware_configs.control_valve[index] && this.state.hardware_configs.control_valve[index][item2.key]}
                              </span>
                                  </Form.Item>

                                  <br/>

                                </Fragment>;

                              })
                            }
                          </Fragment>

                          {this.state.hardware_configs.control_valve && this.state.hardware_configs.control_valve[index] && Boolean(this.state.hardware_configs.control_valve[index].enable) &&
                            <Fragment><Form.Item
                              label="设备编号"
                            >

                              <Input
                                value={this.state.hardware_configs.control_valve && this.state.hardware_configs.control_valve[index] && this.state.hardware_configs.control_valve[index].device_number}
                                onChange={(e) => {
                                  if (!this.state.hardware_configs.control_valve) {
                                    this.state.hardware_configs.control_valve = [];
                                  }
                                  if (this.state.hardware_configs.control_valve.length < 2) {
                                    if (this.state.hardware_configs.control_valve[index]) {
                                      this.state.hardware_configs.control_valve[index].device_number = e.target.value;
                                    } else {
                                      this.state.hardware_configs.control_valve[index] = {};
                                      this.state.hardware_configs.control_valve[index].device_number = e.target.value;
                                    }
                                  } else {
                                    this.state.hardware_configs.control_valve.splice(index, 1, {
                                      ...this.state.hardware_configs.control_valve[index],
                                      device_number: e.target.value,
                                    });
                                  }


                                  this.changeConfig({control_valve: this.state.hardware_configs.control_valve});
                                }}
                              />
                            </Form.Item></Fragment>
                          }
                          {
                            this.props.editRecord &&
                            <Fragment>
                              <Button type={'primary'} onClick={() => {
                                this.setState({
                                  device_number: this.state.hardware_configs.control_valve[index].device_number,
                                  config_index: index,
                                  configModal: true,
                                })
                              }}>调节阀配置</Button>
                            </Fragment>
                          }

                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'数字输入1'} style={{background: '#fafafa'}}>
                    {
                      !(this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[0] && this.state.hardware_configs.digital_input[0].enable) &&
                      <Button type={'primary'} onClick={()=>{
                        this.state.hardware_configs.digital_input[0].enable = 1;
                        this.state.hardware_configs.digital_input[0].alias = '井盖传感器';
                        this.state.hardware_configs.digital_input[0].type = 'DigitalInput003';
                        this.state.hardware_configs.digital_input[0].alarm = 1;
                        this.state.hardware_configs.digital_input[0].normal_upload_interval = 600;
                        this.state.hardware_configs.digital_input[0].alarm_upload_interval = 30;
                        this.setState({
                          hardware_configs:this.state.hardware_configs
                        })
                      }}>添加井盖</Button>

                    }
                    {
                      [{name: '数字输入1'}, {name: '数字输入2'}].map((item, index) => {
                        if (!(this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index].enable)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          <Fragment>

                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].enable) &&
                              [{name: '别名', key: 'alias'}].map((item2, index2) => {
                                return <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >

                              <span>
                                {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                              </span>
                                  </Form.Item>

                                  <br/>

                                </Fragment>;

                              })}

                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) &&
                              [{name: '正常状态数据上传间隔(秒)', key: 'normal_upload_interval'}].map((item2, index2) => {
                                return (this.state.hardware_configs.digital_input[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                  <Fragment key={index2}>
                                    <Form.Item

                                      label={item2.name}
                                    >
                                      <InputNumber
                                        value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                                        onChange={(e) => {
                                          if (!this.state.hardware_configs.digital_input) {
                                            this.state.hardware_configs.digital_input = [];
                                          }
                                          if (this.state.hardware_configs.digital_input.length < 2) {
                                            if (this.state.hardware_configs.digital_input[index]) {
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            } else {
                                              this.state.hardware_configs.digital_input[index] = {};
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            }
                                          } else {
                                            this.state.hardware_configs.digital_input.splice(index, 1, {
                                              ...this.state.hardware_configs.digital_input[index],
                                              [item2.key]: e,
                                            });
                                          }


                                          this.changeConfig({digital_input: this.state.hardware_configs.digital_input});
                                        }}
                                      />
                                    </Form.Item>
                                    <br/>
                                  </Fragment>;

                              })
                            }
                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) &&
                              <Fragment><Form.Item
                                label="是否预警"
                              >
                                <Radio.Group onChange={(e) => {
                                  if (!this.state.hardware_configs.digital_input) {
                                    this.state.hardware_configs.digital_input = [];
                                  }
                                  if (this.state.hardware_configs.digital_input.length < 2) {
                                    if (this.state.hardware_configs.digital_input[index]) {
                                      this.state.hardware_configs.digital_input[index].alarm = e.target.value;
                                    } else {
                                      this.state.hardware_configs.digital_input[index] = {};
                                      this.state.hardware_configs.digital_input[index].alarm = e.target.value;
                                    }
                                  } else {
                                    this.state.hardware_configs.digital_input.splice(index, 1, {
                                      ...this.state.hardware_configs.digital_input[index],
                                      alarm: e.target.value,
                                    });
                                  }
                                  this.changeConfig({digital_input: this.state.hardware_configs.digital_input});
                                }}
                                             value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index].alarm}>
                                  <Radio value={1}>报警</Radio>
                                  <Radio value={0}>不报警</Radio>
                                </Radio.Group>
                              </Form.Item>
                                <br/>
                              </Fragment>
                            }
                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) && Boolean(this.state.hardware_configs.digital_input[index].alarm) &&
                              [{
                                name: '报警状态数据上传间隔(秒)',
                                key: 'alarm_upload_interval',
                              }].map((item2, index2) => {
                                return (this.state.hardware_configs.digital_input[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                  <Fragment key={index2}>
                                    <Form.Item

                                      label={item2.name}
                                    >
                                      <InputNumber
                                        value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                                        onChange={(e) => {
                                          if (!this.state.hardware_configs.digital_input) {
                                            this.state.hardware_configs.digital_input = [];
                                          }
                                          if (this.state.hardware_configs.digital_input.length < 2) {
                                            if (this.state.hardware_configs.digital_input[index]) {
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            } else {
                                              this.state.hardware_configs.digital_input[index] = {};
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            }
                                          } else {
                                            this.state.hardware_configs.digital_input.splice(index, 1, {
                                              ...this.state.hardware_configs.digital_input[index],
                                              [item2.key]: e,
                                            });
                                          }


                                          this.changeConfig({digital_input: this.state.hardware_configs.digital_input});
                                        }}
                                      />
                                    </Form.Item>

                                  </Fragment>;

                              })
                            }


                          </Fragment>


                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
              </Form>
            }
            {
              (Number(this.state.templateId) === 23) &&
              <Form layout="inline" style={{paddingBottom: '50px'}}>
                <div className={styles.box_item} style={{paddingTop: '12px'}}>
                  <Tabs size='small' defaultActiveKey={'device'} style={{background: '#fafafa'}}>
                    <TabPane tab={'设备信息'} key={'device'}>

                      <Form.Item
                        label="数据上传间隔(分钟)"
                      >
                        <InputNumber
                          value={this.state.hardware_configs.device && this.state.hardware_configs.device[0].upload_interval}
                          onChange={(e) => {
                            if (!this.state.hardware_configs.device) {
                              this.state.hardware_configs.device = [];
                            }
                            if (this.state.hardware_configs.device.length < 1) {
                              this.state.hardware_configs.device[0] = {};
                              this.state.hardware_configs.device[0].upload_interval = e;
                            } else {
                              this.state.hardware_configs.device.splice(0, 1, {
                                ...this.state.hardware_configs.device[0],
                                upload_interval: e,
                              });
                            }
                            this.changeConfig({device: this.state.hardware_configs.device});
                          }}
                        />
                      </Form.Item>
                    </TabPane>
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'传感器1'} style={{background: '#fafafa'}}>
                    {
                      [{name: '传感器1'}, {name: '传感器2'}, {name: '传感器3'}, {name: '传感器4'}].map((item, index) => {

                        if (!(this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index].type)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          {
                            this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{name: '别名', key: 'alias'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item
                                  label={item2.name}>

                                <span>
                                 {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                </span>
                                </Form.Item>
                                <br/>
                              </Fragment>;

                            })
                          }


                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{name: '上传间隔(秒)', key: 'normal_upload_interval'}, {
                              name: `波动值(${this.state.hardware_configs.sensor[index].type === 'sensor001' ? 'Mpa' : 'm'})`,
                              key: 'fluctuation_value',
                            }, {
                              name: `满量程${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '(Mpa)' : '(m)'}`,
                              key: 'range_max'
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>

                                  <br/>

                                </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            <Fragment><Form.Item
                              label="是否预警"
                            >
                              <Radio.Group
                                onChange={(e) => {
                                  if (!this.state.hardware_configs.sensor) {
                                    this.state.hardware_configs.sensor = [];
                                  }
                                  if (this.state.hardware_configs.sensor.length < 4) {
                                    if (this.state.hardware_configs.sensor[index]) {
                                      this.state.hardware_configs.sensor[index].alarm = e.target.value;
                                    } else {
                                      this.state.hardware_configs.sensor[index] = {};
                                      this.state.hardware_configs.sensor[index].alarm = e.target.value;
                                    }
                                  } else {
                                    this.state.hardware_configs.sensor.splice(index, 1, {
                                      ...this.state.hardware_configs.sensor[index],
                                      alarm: e.target.value,
                                    });
                                  }
                                  this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                }}
                                value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index].alarm}>
                                <Radio value={1}>报警</Radio>
                                <Radio value={0}>不报警</Radio>
                              </Radio.Group>
                            </Form.Item>
                              <br/>
                            </Fragment>
                          }

                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{
                              name: `${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '过压值(Mpa)' : '过高(m)'}`,
                              key: 'over'
                            }, {
                              name: `${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '欠压值(Mpa)' : '过低(m)'}`,
                              key: 'under',
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>
                                  {index2 === 2 && <br/>}
                                </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) && Boolean(this.state.hardware_configs.sensor[index].alarm) &&
                            [{
                              name: '报警间隔(秒)',
                              key: 'alarm_upload_interval',
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>

                                </Fragment>;

                            })
                          }


                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'数字输入1'} style={{background: '#fafafa'}}>
                    {
                      !(this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[0] && this.state.hardware_configs.digital_input[0].enable) &&
                      <Button type={'primary'} onClick={()=>{
                        this.state.hardware_configs.digital_input[0].enable = 1;
                        this.state.hardware_configs.digital_input[0].alias = '井盖传感器';
                        this.state.hardware_configs.digital_input[0].type = 'DigitalInput003';
                        this.state.hardware_configs.digital_input[0].alarm = 1;
                        this.state.hardware_configs.digital_input[0].normal_upload_interval = 600;
                        this.state.hardware_configs.digital_input[0].alarm_upload_interval = 30;
                        this.setState({
                          hardware_configs:this.state.hardware_configs
                        })
                      }}>添加井盖</Button>

                    }
                    {
                      [{name: '数字输入1'}, {name: '数字输入2'}].map((item, index) => {
                        if (!(this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index].enable)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          <Fragment>

                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].enable) &&
                              [{name: '别名', key: 'alias'}].map((item2, index2) => {
                                return <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >

                              <span>
                                {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                              </span>
                                  </Form.Item>

                                  <br/>

                                </Fragment>;

                              })}

                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) &&
                              [{name: '正常状态数据上传间隔(秒)', key: 'normal_upload_interval'}].map((item2, index2) => {
                                return (this.state.hardware_configs.digital_input[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                  <Fragment key={index2}>
                                    <Form.Item

                                      label={item2.name}
                                    >
                                      <InputNumber
                                        value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                                        onChange={(e) => {
                                          if (!this.state.hardware_configs.digital_input) {
                                            this.state.hardware_configs.digital_input = [];
                                          }
                                          if (this.state.hardware_configs.digital_input.length < 2) {
                                            if (this.state.hardware_configs.digital_input[index]) {
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            } else {
                                              this.state.hardware_configs.digital_input[index] = {};
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            }
                                          } else {
                                            this.state.hardware_configs.digital_input.splice(index, 1, {
                                              ...this.state.hardware_configs.digital_input[index],
                                              [item2.key]: e,
                                            });
                                          }


                                          this.changeConfig({digital_input: this.state.hardware_configs.digital_input});
                                        }}
                                      />
                                    </Form.Item>
                                    <br/>
                                  </Fragment>;

                              })
                            }
                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) &&
                              <Fragment><Form.Item
                                label="是否预警"
                              >
                                <Radio.Group onChange={(e) => {
                                  if (!this.state.hardware_configs.digital_input) {
                                    this.state.hardware_configs.digital_input = [];
                                  }
                                  if (this.state.hardware_configs.digital_input.length < 2) {
                                    if (this.state.hardware_configs.digital_input[index]) {
                                      this.state.hardware_configs.digital_input[index].alarm = e.target.value;
                                    } else {
                                      this.state.hardware_configs.digital_input[index] = {};
                                      this.state.hardware_configs.digital_input[index].alarm = e.target.value;
                                    }
                                  } else {
                                    this.state.hardware_configs.digital_input.splice(index, 1, {
                                      ...this.state.hardware_configs.digital_input[index],
                                      alarm: e.target.value,
                                    });
                                  }
                                  this.changeConfig({digital_input: this.state.hardware_configs.digital_input});
                                }}
                                             value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index].alarm}>
                                  <Radio value={1}>报警</Radio>
                                  <Radio value={0}>不报警</Radio>
                                </Radio.Group>
                              </Form.Item>
                                <br/>
                              </Fragment>
                            }
                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) && Boolean(this.state.hardware_configs.digital_input[index].alarm) &&
                              [{
                                name: '报警状态数据上传间隔(秒)',
                                key: 'alarm_upload_interval',
                              }].map((item2, index2) => {
                                return (this.state.hardware_configs.digital_input[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                  <Fragment key={index2}>
                                    <Form.Item

                                      label={item2.name}
                                    >
                                      <InputNumber
                                        value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                                        onChange={(e) => {
                                          if (!this.state.hardware_configs.digital_input) {
                                            this.state.hardware_configs.digital_input = [];
                                          }
                                          if (this.state.hardware_configs.digital_input.length < 2) {
                                            if (this.state.hardware_configs.digital_input[index]) {
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            } else {
                                              this.state.hardware_configs.digital_input[index] = {};
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            }
                                          } else {
                                            this.state.hardware_configs.digital_input.splice(index, 1, {
                                              ...this.state.hardware_configs.digital_input[index],
                                              [item2.key]: e,
                                            });
                                          }


                                          this.changeConfig({digital_input: this.state.hardware_configs.digital_input});
                                        }}
                                      />
                                    </Form.Item>

                                  </Fragment>;

                              })
                            }


                          </Fragment>


                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
              </Form>
            }
            {
              Number(this.state.templateId) === 19 &&
              <Form layout="inline" style={{paddingBottom: '50px'}}>
                <div className={styles.box_item} style={{paddingTop: '12px'}}>
                  <Tabs size='small' defaultActiveKey={'device'} style={{background: '#fafafa'}}>
                    <TabPane tab={'设备信息'} key={'device'}>

                      <Form.Item
                        label="数据上传间隔(分钟)"
                      >
                        <InputNumber
                          value={this.state.hardware_configs.device && this.state.hardware_configs.device[0].upload_interval}
                          onChange={(e) => {
                            if (!this.state.hardware_configs.device) {
                              this.state.hardware_configs.device = [];
                            }
                            if (this.state.hardware_configs.device.length < 1) {
                              this.state.hardware_configs.device[0] = {};
                              this.state.hardware_configs.device[0].upload_interval = e;
                            } else {
                              this.state.hardware_configs.device.splice(0, 1, {
                                ...this.state.hardware_configs.device[0],
                                upload_interval: e,
                              });
                            }
                            this.changeConfig({device: this.state.hardware_configs.device});
                          }}
                        />
                      </Form.Item>
                    </TabPane>
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'传感器1'} style={{background: '#fafafa'}}>
                    {
                      [{name: '传感器1'}, {name: '传感器2'}, {name: '传感器3'}, {name: '传感器4'}].map((item, index) => {

                        if (!(this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index].type)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          {
                            this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{name: '别名', key: 'alias'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item
                                  label={item2.name}>

                                <span>
                                 {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                </span>
                                </Form.Item>
                                <br/>
                              </Fragment>;

                            })
                          }


                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{name: '上传间隔(秒)', key: 'normal_upload_interval'}, {
                              name: `波动值(${this.state.hardware_configs.sensor[index].type === 'sensor001' ? 'Mpa' : 'm'})`,
                              key: 'fluctuation_value',
                            }, {
                              name: `满量程${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '(Mpa)' : '(m)'}`,
                              key: 'range_max'
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>

                                  <br/>

                                </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            <Fragment><Form.Item
                              label="是否预警"
                            >
                              <Radio.Group
                                onChange={(e) => {
                                  if (!this.state.hardware_configs.sensor) {
                                    this.state.hardware_configs.sensor = [];
                                  }
                                  if (this.state.hardware_configs.sensor.length < 4) {
                                    if (this.state.hardware_configs.sensor[index]) {
                                      this.state.hardware_configs.sensor[index].alarm = e.target.value;
                                    } else {
                                      this.state.hardware_configs.sensor[index] = {};
                                      this.state.hardware_configs.sensor[index].alarm = e.target.value;
                                    }
                                  } else {
                                    this.state.hardware_configs.sensor.splice(index, 1, {
                                      ...this.state.hardware_configs.sensor[index],
                                      alarm: e.target.value,
                                    });
                                  }
                                  this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                }}
                                value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index].alarm}>
                                <Radio value={1}>报警</Radio>
                                <Radio value={0}>不报警</Radio>
                              </Radio.Group>
                            </Form.Item>
                              <br/>
                            </Fragment>
                          }

                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{
                              name: `${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '过压值(Mpa)' : '过高(m)'}`,
                              key: 'over'
                            }, {
                              name: `${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '欠压值(Mpa)' : '过低(m)'}`,
                              key: 'under',
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>
                                  {index2 === 2 && <br/>}
                                </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) && Boolean(this.state.hardware_configs.sensor[index].alarm) &&
                            [{
                              name: '报警间隔(秒)',
                              key: 'alarm_upload_interval',
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>

                                </Fragment>;

                            })
                          }


                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'Modbus1'} style={{background: '#fafafa'}}>
                    {
                      [{name: 'Modbus1'}, {name: 'Modbus2'}, {name: 'Modbus3'}, {name: 'Modbus2'}].map((item, index) => {
                        if (!(this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index].type)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={index}>
                          <Fragment><Form.Item
                            label='设备类型'>

                      <span>
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},
                              {key: 'DOUBLE-VALVE-PLC', name: '双阀PLC'},
                              {key: 'Modbus018', name: '液位探测器Modbus'},
                              {key: 'Modbus020', name: '调流阀Modbus'},
                              {key: 'Modbus023', name: 'Modbus023'},
                              {
                                key: 0,
                                name: '无',
                              }], o => o.key === this.state.hardware_configs.modbus_03[index].type) &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},
                              {key: 'DOUBLE-VALVE-PLC', name: '双阀PLC'},
                              {key: 'Modbus018', name: '液位探测器Modbus'},
                              {key: 'Modbus020', name: '调流阀Modbus'},
                              {key: 'Modbus023', name: 'Modbus023'},
                              {
                                key: 0,
                                name: '无',
                              }], o => o.key === this.state.hardware_configs.modbus_03[index].type).name}
                        </span>
                          </Form.Item>
                          </Fragment>
                          <br/>
                          {
                            this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '别名', key: 'alias'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >

                            <span>
                              {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                            </span>
                                </Form.Item>

                                <br/>

                              </Fragment>;

                            })
                          }


                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            this.state.hardware_configs.modbus_03[index].type === 'Modbus018' &&
                            [{name: '从机地址', key: 'slave_address'},{name: '数据上传间隔(秒)', key: 'upload_interval'}, {
                              name: '报警水位(米)',
                              key: 'alarm_water_level'
                            }].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >
                                  <InputNumber
                                    value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    onChange={(e) => {
                                      if (!this.state.hardware_configs.modbus_03) {
                                        this.state.hardware_configs.modbus_03 = [];
                                      }
                                      if (this.state.hardware_configs.modbus_03.length < 2) {
                                        if (this.state.hardware_configs.modbus_03[index]) {
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        } else {
                                          this.state.hardware_configs.modbus_03[index] = {};
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        }
                                      } else {
                                        this.state.hardware_configs.modbus_03.splice(index, 1, {
                                          ...this.state.hardware_configs.modbus_03[index],
                                          [item2.key]: e,
                                        });
                                      }


                                      this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                    }}
                                  />
                                </Form.Item>
                              </Fragment>;

                            })
                          }

                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            this.state.hardware_configs.modbus_03[index].type === 'Modbus023' &&
                            <Fragment>
                              {
                                [{
                                  name: '控制方法',
                                  key: 'control_mode',
                                }].map((item2, index2) => {
                                  return <Form.Item

                                    key={index2}
                                    label={item2.name}
                                  >
                                    <Select
                                      style={{width: '140px'}}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.modbus_03) {
                                          this.state.hardware_configs.modbus_03 = [];
                                        }
                                        if (this.state.hardware_configs.modbus_03.length < 4) {
                                          if (this.state.hardware_configs.modbus_03[index]) {
                                            this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.modbus_03[index] = {};
                                            this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.modbus_03.splice(index, 1, {
                                            ...this.state.hardware_configs.modbus_03[index],
                                            [item2.key]: e,
                                          });
                                        }
                                        this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                      }}

                                      value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    >
                                      {[{key: 0, name: '压力控制模式'}, {key: 1, name: '开度控制模式'}].map((item, key) => {
                                        return (
                                          <Option key={key}
                                                  value={item.key}>{item.name}</Option>
                                        );
                                      })}
                                    </Select>
                                  </Form.Item>;
                                })
                              }
                            </Fragment>
                          }
                          <br/>
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            this.state.hardware_configs.modbus_03[index].type === 'Modbus023' &&this.state.hardware_configs.modbus_03[index].control_mode === 0 &&
                            [ {
                              name: '设置压力值(Mpa)',
                              key: 'target_pressure_value'
                            }].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >
                                  <InputNumber
                                    step={0.1}
                                    value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    onChange={(e) => {
                                      if (!this.state.hardware_configs.modbus_03) {
                                        this.state.hardware_configs.modbus_03 = [];
                                      }
                                      if (this.state.hardware_configs.modbus_03.length < 2) {
                                        if (this.state.hardware_configs.modbus_03[index]) {
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        } else {
                                          this.state.hardware_configs.modbus_03[index] = {};
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        }
                                      } else {
                                        this.state.hardware_configs.modbus_03.splice(index, 1, {
                                          ...this.state.hardware_configs.modbus_03[index],
                                          [item2.key]: e,
                                        });
                                      }


                                      this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                    }}
                                  />
                                </Form.Item>
                              </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            this.state.hardware_configs.modbus_03[index].type === 'Modbus023' &&this.state.hardware_configs.modbus_03[index].control_mode === 1 &&
                            [ {
                              name: '阀位控制设定值(%)',
                              key: 'target_opening_value'
                            }].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >
                                  <InputNumber
                                    min={0}
                                    max={100}
                                    value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    onChange={(e) => {
                                      if (!this.state.hardware_configs.modbus_03) {
                                        this.state.hardware_configs.modbus_03 = [];
                                      }
                                      if (this.state.hardware_configs.modbus_03.length < 2) {
                                        if (this.state.hardware_configs.modbus_03[index]) {
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        } else {
                                          this.state.hardware_configs.modbus_03[index] = {};
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        }
                                      } else {
                                        this.state.hardware_configs.modbus_03.splice(index, 1, {
                                          ...this.state.hardware_configs.modbus_03[index],
                                          [item2.key]: e,
                                        });
                                      }


                                      this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                    }}
                                  />
                                </Form.Item>
                              </Fragment>;

                            })
                          }
                          <br/>

                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            this.state.hardware_configs.modbus_03[index].type === 'Modbus023' &&
                            [{name: '从机地址', key: 'slave_address'},{name: '数据上传间隔(秒)', key: 'upload_interval'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >
                                  <InputNumber
                                    min={0}
                                    value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    onChange={(e) => {
                                      if (!this.state.hardware_configs.modbus_03) {
                                        this.state.hardware_configs.modbus_03 = [];
                                      }
                                      if (this.state.hardware_configs.modbus_03.length < 2) {
                                        if (this.state.hardware_configs.modbus_03[index]) {
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        } else {
                                          this.state.hardware_configs.modbus_03[index] = {};
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        }
                                      } else {
                                        this.state.hardware_configs.modbus_03.splice(index, 1, {
                                          ...this.state.hardware_configs.modbus_03[index],
                                          [item2.key]: e,
                                        });
                                      }


                                      this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                    }}
                                  />
                                </Form.Item>
                              </Fragment>;

                            })
                          }
                          <br/>
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            this.state.hardware_configs.modbus_03[index].type === 'Modbus023' &&
                            <Fragment>
                              {
                                [{
                                  name: '蝶阀1动作',
                                  key: 'butterfly_valve1_status',
                                }, {
                                  name: '蝶阀2动作',
                                  key: 'butterfly_valve2_status',
                                }, {
                                  name: '蝶阀3动作',
                                  key: 'butterfly_valve3_status',
                                }, {
                                  name: '蝶阀4动作',
                                  key: 'butterfly_valve4_status',
                                }].map((item2, index2) => {
                                  return <Form.Item

                                    key={index2}
                                    label={item2.name}
                                  >
                                    <Select
                                      style={{width: '80px'}}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.modbus_03) {
                                          this.state.hardware_configs.modbus_03 = [];
                                        }
                                        if (this.state.hardware_configs.modbus_03.length < 4) {
                                          if (this.state.hardware_configs.modbus_03[index]) {
                                            this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.modbus_03[index] = {};
                                            this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.modbus_03.splice(index, 1, {
                                            ...this.state.hardware_configs.modbus_03[index],
                                            [item2.key]: e,
                                          });
                                        }
                                        this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                      }}

                                      value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    >
                                      {[{key: 1, name: '开'}, {key: 2, name: '停'}, {
                                        key: 4,
                                        name: '关',
                                      }].map((item, key) => {
                                        return (
                                          <Option key={key}
                                                  value={item.key}>{item.name}</Option>
                                        );
                                      })}
                                    </Select>
                                  </Form.Item>;

                                })

                              }
                            </Fragment>
                          }

                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'数字输入1'} style={{background: '#fafafa'}}>
                    {
                      !(this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[0] && this.state.hardware_configs.digital_input[0].enable) &&
                      <Button type={'primary'} onClick={()=>{
                        this.state.hardware_configs.digital_input[0].enable = 1;
                        this.state.hardware_configs.digital_input[0].alias = '井盖传感器';
                        this.state.hardware_configs.digital_input[0].type = 'DigitalInput003';
                        this.state.hardware_configs.digital_input[0].alarm = 1;
                        this.state.hardware_configs.digital_input[0].normal_upload_interval = 600;
                        this.state.hardware_configs.digital_input[0].alarm_upload_interval = 30;
                        this.setState({
                          hardware_configs:this.state.hardware_configs
                        })
                      }}>添加井盖</Button>

                    }
                    {
                      [{name: '数字输入1'}, {name: '数字输入2'}].map((item, index) => {
                        if (!(this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index].enable)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          <Fragment>

                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].enable) &&
                              [{name: '别名', key: 'alias'}].map((item2, index2) => {
                                return <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >

                              <span>
                                {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                              </span>
                                  </Form.Item>

                                  <br/>

                                </Fragment>;

                              })}

                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) &&
                              [{name: '正常状态数据上传间隔(秒)', key: 'normal_upload_interval'}].map((item2, index2) => {
                                return (this.state.hardware_configs.digital_input[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                  <Fragment key={index2}>
                                    <Form.Item

                                      label={item2.name}
                                    >
                                      <InputNumber
                                        value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                                        onChange={(e) => {
                                          if (!this.state.hardware_configs.digital_input) {
                                            this.state.hardware_configs.digital_input = [];
                                          }
                                          if (this.state.hardware_configs.digital_input.length < 2) {
                                            if (this.state.hardware_configs.digital_input[index]) {
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            } else {
                                              this.state.hardware_configs.digital_input[index] = {};
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            }
                                          } else {
                                            this.state.hardware_configs.digital_input.splice(index, 1, {
                                              ...this.state.hardware_configs.digital_input[index],
                                              [item2.key]: e,
                                            });
                                          }


                                          this.changeConfig({digital_input: this.state.hardware_configs.digital_input});
                                        }}
                                      />
                                    </Form.Item>
                                    <br/>
                                  </Fragment>;

                              })
                            }
                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) &&
                              <Fragment><Form.Item
                                label="是否预警"
                              >
                                <Radio.Group onChange={(e) => {
                                  if (!this.state.hardware_configs.digital_input) {
                                    this.state.hardware_configs.digital_input = [];
                                  }
                                  if (this.state.hardware_configs.digital_input.length < 2) {
                                    if (this.state.hardware_configs.digital_input[index]) {
                                      this.state.hardware_configs.digital_input[index].alarm = e.target.value;
                                    } else {
                                      this.state.hardware_configs.digital_input[index] = {};
                                      this.state.hardware_configs.digital_input[index].alarm = e.target.value;
                                    }
                                  } else {
                                    this.state.hardware_configs.digital_input.splice(index, 1, {
                                      ...this.state.hardware_configs.digital_input[index],
                                      alarm: e.target.value,
                                    });
                                  }
                                  this.changeConfig({digital_input: this.state.hardware_configs.digital_input});
                                }}
                                             value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index].alarm}>
                                  <Radio value={1}>报警</Radio>
                                  <Radio value={0}>不报警</Radio>
                                </Radio.Group>
                              </Form.Item>
                                <br/>
                              </Fragment>
                            }
                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) && Boolean(this.state.hardware_configs.digital_input[index].alarm) &&
                              [{
                                name: '报警状态数据上传间隔(秒)',
                                key: 'alarm_upload_interval',
                              }].map((item2, index2) => {
                                return (this.state.hardware_configs.digital_input[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                  <Fragment key={index2}>
                                    <Form.Item

                                      label={item2.name}
                                    >
                                      <InputNumber
                                        value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                                        onChange={(e) => {
                                          if (!this.state.hardware_configs.digital_input) {
                                            this.state.hardware_configs.digital_input = [];
                                          }
                                          if (this.state.hardware_configs.digital_input.length < 2) {
                                            if (this.state.hardware_configs.digital_input[index]) {
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            } else {
                                              this.state.hardware_configs.digital_input[index] = {};
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            }
                                          } else {
                                            this.state.hardware_configs.digital_input.splice(index, 1, {
                                              ...this.state.hardware_configs.digital_input[index],
                                              [item2.key]: e,
                                            });
                                          }


                                          this.changeConfig({digital_input: this.state.hardware_configs.digital_input});
                                        }}
                                      />
                                    </Form.Item>

                                  </Fragment>;

                              })
                            }


                          </Fragment>


                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
              </Form>
            }
            {
              Number(this.state.templateId) === 29 &&
              <Form layout="inline" style={{paddingBottom: '50px'}}>
                <div className={styles.box_item} style={{paddingTop: '12px'}}>
                  <Tabs size='small' defaultActiveKey={'device'} style={{background: '#fafafa'}}>
                    <TabPane tab={'设备信息'} key={'device'}>

                      <Form.Item
                        label="数据上传间隔(分钟)"
                      >
                        <InputNumber
                          value={this.state.hardware_configs.device && this.state.hardware_configs.device[0].upload_interval}
                          onChange={(e) => {
                            if (!this.state.hardware_configs.device) {
                              this.state.hardware_configs.device = [];
                            }
                            if (this.state.hardware_configs.device.length < 1) {
                              this.state.hardware_configs.device[0] = {};
                              this.state.hardware_configs.device[0].upload_interval = e;
                            } else {
                              this.state.hardware_configs.device.splice(0, 1, {
                                ...this.state.hardware_configs.device[0],
                                upload_interval: e,
                              });
                            }
                            this.changeConfig({device: this.state.hardware_configs.device});
                          }}
                        />
                      </Form.Item>
                    </TabPane>
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'传感器1'} style={{background: '#fafafa'}}>
                    {
                      [{name: '传感器1'}, {name: '传感器2'}, {name: '传感器3'}, {name: '传感器4'}].map((item, index) => {

                        if (!(this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index].type)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          {
                            this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{name: '别名', key: 'alias'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item
                                  label={item2.name}>

                                <span>
                                 {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                </span>
                                </Form.Item>
                                <br/>
                              </Fragment>;

                            })
                          }


                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{name: '上传间隔(秒)', key: 'normal_upload_interval'}, {
                              name: `波动值(${this.state.hardware_configs.sensor[index].type === 'sensor001' ? 'Mpa' : 'm'})`,
                              key: 'fluctuation_value',
                            }, {
                              name: `满量程${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '(Mpa)' : '(m)'}`,
                              key: 'range_max'
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>

                                  <br/>

                                </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            <Fragment><Form.Item
                              label="是否预警"
                            >
                              <Radio.Group
                                onChange={(e) => {
                                  if (!this.state.hardware_configs.sensor) {
                                    this.state.hardware_configs.sensor = [];
                                  }
                                  if (this.state.hardware_configs.sensor.length < 4) {
                                    if (this.state.hardware_configs.sensor[index]) {
                                      this.state.hardware_configs.sensor[index].alarm = e.target.value;
                                    } else {
                                      this.state.hardware_configs.sensor[index] = {};
                                      this.state.hardware_configs.sensor[index].alarm = e.target.value;
                                    }
                                  } else {
                                    this.state.hardware_configs.sensor.splice(index, 1, {
                                      ...this.state.hardware_configs.sensor[index],
                                      alarm: e.target.value,
                                    });
                                  }
                                  this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                }}
                                value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index].alarm}>
                                <Radio value={1}>报警</Radio>
                                <Radio value={0}>不报警</Radio>
                              </Radio.Group>
                            </Form.Item>
                              <br/>
                            </Fragment>
                          }

                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{
                              name: `${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '过压值(Mpa)' : '过高(m)'}`,
                              key: 'over'
                            }, {
                              name: `${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '欠压值(Mpa)' : '过低(m)'}`,
                              key: 'under',
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>
                                  {index2 === 2 && <br/>}
                                </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) && Boolean(this.state.hardware_configs.sensor[index].alarm) &&
                            [{
                              name: '报警间隔(秒)',
                              key: 'alarm_upload_interval',
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>

                                </Fragment>;

                            })
                          }


                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'Modbus1'} style={{background: '#fafafa'}}>
                    {
                      [{name: 'Modbus1'}, {name: 'Modbus2'}, {name: 'Modbus3'}].map((item, index) => {
                        if (!(this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index].type)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          <Fragment><Form.Item
                            label='设备类型'>

                      <span>
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},
                              {key: 'DOUBLE-VALVE-PLC', name: '双阀PLC'},
                              {key: 'Modbus018', name: '液位探测器Modbus'},
                              {key: 'Modbus020', name: '调流阀Modbus'},
                              {key: 'Modbus015_1', name: 'Modbus015_1'},
                              {key: 'Modbus015_2', name: 'Modbus015_2'},
                              {
                                key: 0,
                                name: '无',
                              }], o => o.key === this.state.hardware_configs.modbus_03[index].type) &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},
                              {key: 'DOUBLE-VALVE-PLC', name: '双阀PLC'},
                              {key: 'Modbus018', name: '液位探测器Modbus'},
                              {key: 'Modbus020', name: '调流阀Modbus'},
                              {key: 'Modbus015_1', name: 'Modbus015_1'},
                              {key: 'Modbus015_2', name: 'Modbus015_2'},
                              {
                                key: 0,
                                name: '无',
                              }], o => o.key === this.state.hardware_configs.modbus_03[index].type).name}
                        </span>
                          </Form.Item>
                          </Fragment>
                          <br/>
                          {
                            this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '别名', key: 'alias'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >

                            <span>
                              {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                            </span>
                                </Form.Item>

                                <br/>

                              </Fragment>;

                            })
                          }


                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) && this.state.hardware_configs.modbus_03[index].type === 'Modbus018' &&
                            [{name: '报警水位(米)', key: 'alarm_water_level'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >
                                  <InputNumber
                                    value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    onChange={(e) => {
                                      if (!this.state.hardware_configs.modbus_03) {
                                        this.state.hardware_configs.modbus_03 = [];
                                      }
                                      if (this.state.hardware_configs.modbus_03.length < 2) {
                                        if (this.state.hardware_configs.modbus_03[index]) {
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        } else {
                                          this.state.hardware_configs.modbus_03[index] = {};
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        }
                                      } else {
                                        this.state.hardware_configs.modbus_03.splice(index, 1, {
                                          ...this.state.hardware_configs.modbus_03[index],
                                          [item2.key]: e,
                                        });
                                      }


                                      this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                    }}
                                  />
                                </Form.Item>
                              </Fragment>;

                            })
                          }

                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) && this.state.hardware_configs.modbus_03[index].type === 'Modbus020' &&
                            [{name: '设置压力值(Mpa)', key: 'target_pressure_value'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >
                                  <InputNumber
                                    value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    onChange={(e) => {
                                      if (!this.state.hardware_configs.modbus_03) {
                                        this.state.hardware_configs.modbus_03 = [];
                                      }
                                      if (this.state.hardware_configs.modbus_03.length < 2) {
                                        if (this.state.hardware_configs.modbus_03[index]) {
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        } else {
                                          this.state.hardware_configs.modbus_03[index] = {};
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        }
                                      } else {
                                        this.state.hardware_configs.modbus_03.splice(index, 1, {
                                          ...this.state.hardware_configs.modbus_03[index],
                                          [item2.key]: e,
                                        });
                                      }


                                      this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                    }}
                                  />
                                </Form.Item>
                              </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            this.state.hardware_configs.modbus_03[index].type === 'Modbus015_1' &&
                            <Fragment>
                              {
                                [{
                                  name: '蝶阀1动作',
                                  key: 'butterfly_valve1_status',
                                }, {
                                  name: '蝶阀2动作',
                                  key: 'butterfly_valve2_status',
                                }, {
                                  name: '蝶阀3动作',
                                  key: 'butterfly_valve3_status',
                                }, {
                                  name: '蝶阀4动作',
                                  key: 'butterfly_valve4_status',
                                }].map((item2, index2) => {
                                  return <Form.Item

                                    key={index2}
                                    label={item2.name}
                                  >
                                    <Select
                                      style={{width: '80px'}}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.modbus_03) {
                                          this.state.hardware_configs.modbus_03 = [];
                                        }
                                        if (this.state.hardware_configs.modbus_03.length < 4) {
                                          if (this.state.hardware_configs.modbus_03[index]) {
                                            this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.modbus_03[index] = {};
                                            this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.modbus_03.splice(index, 1, {
                                            ...this.state.hardware_configs.modbus_03[index],
                                            [item2.key]: e,
                                          });
                                        }
                                        this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                      }}

                                      value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    >
                                      {[{key: 1, name: '开'}, {key: 2, name: '停'}, {
                                        key: 4,
                                        name: '关',
                                      }].map((item, key) => {
                                        return (
                                          <Option key={key}
                                                  value={item.key}>{item.name}</Option>
                                        );
                                      })}
                                    </Select>
                                  </Form.Item>;

                                })

                              }
                            </Fragment>
                          }
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '从机地址', key: 'slave_address'}, {
                              name: '数据上传间隔(秒)',
                              key: 'upload_interval'
                            }].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >
                                  <InputNumber
                                    min={0}
                                    value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    onChange={(e) => {
                                      if (!this.state.hardware_configs.modbus_03) {
                                        this.state.hardware_configs.modbus_03 = [];
                                      }
                                      if (this.state.hardware_configs.modbus_03.length < 2) {
                                        if (this.state.hardware_configs.modbus_03[index]) {
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        } else {
                                          this.state.hardware_configs.modbus_03[index] = {};
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        }
                                      } else {
                                        this.state.hardware_configs.modbus_03.splice(index, 1, {
                                          ...this.state.hardware_configs.modbus_03[index],
                                          [item2.key]: e,
                                        });
                                      }


                                      this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                    }}
                                  />
                                </Form.Item>
                              </Fragment>;

                            })
                          }
                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>

              </Form>
            }
            {
              Number(this.state.templateId) === 13 &&
              <Form layout="inline" style={{paddingBottom: '50px'}}>
                <div className={styles.box_item} style={{paddingTop: '12px'}}>
                  <Tabs size='small' defaultActiveKey={'device'} style={{background: '#fafafa'}}>
                    <TabPane tab={'设备信息'} key={'device'}>

                      <Form.Item
                        label="数据上传间隔(分钟)"
                      >
                        <InputNumber
                          value={this.state.hardware_configs.device && this.state.hardware_configs.device[0].upload_interval}
                          onChange={(e) => {
                            if (!this.state.hardware_configs.device) {
                              this.state.hardware_configs.device = [];
                            }
                            if (this.state.hardware_configs.device.length < 1) {
                              this.state.hardware_configs.device[0] = {};
                              this.state.hardware_configs.device[0].upload_interval = e;
                            } else {
                              this.state.hardware_configs.device.splice(0, 1, {
                                ...this.state.hardware_configs.device[0],
                                upload_interval: e,
                              });
                            }
                            this.changeConfig({device: this.state.hardware_configs.device});
                          }}
                        />
                      </Form.Item>
                      <Form.Item
                        label="管径"
                      >
                        <Input
                          addonBefore="DN"
                          style={{width: '120px'}}
                          value={this.state.hardware_configs.customize && this.state.hardware_configs.customize.caliber}
                          onChange={(e) => {
                            if (!this.state.hardware_configs.customize) {
                              this.state.hardware_configs.customize = {}
                            }
                            this.state.hardware_configs.customize = {
                              ...this.state.hardware_configs.customize,
                              caliber: e.target.value
                            }
                            // console.log('this.state.hardware_configs.customize', this.state.hardware_configs.customize)
                            this.changeConfig({customize: this.state.hardware_configs.customize})
                          }}
                        />
                      </Form.Item>

                    </TabPane>
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'传感器1'} style={{background: '#fafafa'}}>
                    {
                      [{name: '传感器1'}, {name: '传感器2'}, {name: '传感器3'}, {name: '传感器4'}].map((item, index) => {

                        if (!(this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index].type)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          {
                            this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{name: '别名', key: 'alias'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item
                                  label={item2.name}>

                                <span>
                                 {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                </span>
                                </Form.Item>
                                <br/>
                              </Fragment>;

                            })
                          }


                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{name: '上传间隔(秒)', key: 'normal_upload_interval'}, {
                              name: `波动值(${this.state.hardware_configs.sensor[index].type === 'sensor001' ? 'Mpa' : 'm'})`,
                              key: 'fluctuation_value',
                            }, {
                              name: `满量程${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '(Mpa)' : '(m)'}`,
                              key: 'range_max'
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>

                                  <br/>

                                </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            <Fragment><Form.Item
                              label="是否预警"
                            >
                              <Radio.Group
                                onChange={(e) => {
                                  if (!this.state.hardware_configs.sensor) {
                                    this.state.hardware_configs.sensor = [];
                                  }
                                  if (this.state.hardware_configs.sensor.length < 4) {
                                    if (this.state.hardware_configs.sensor[index]) {
                                      this.state.hardware_configs.sensor[index].alarm = e.target.value;
                                    } else {
                                      this.state.hardware_configs.sensor[index] = {};
                                      this.state.hardware_configs.sensor[index].alarm = e.target.value;
                                    }
                                  } else {
                                    this.state.hardware_configs.sensor.splice(index, 1, {
                                      ...this.state.hardware_configs.sensor[index],
                                      alarm: e.target.value,
                                    });
                                  }
                                  this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                }}
                                value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index].alarm}>
                                <Radio value={1}>报警</Radio>
                                <Radio value={0}>不报警</Radio>
                              </Radio.Group>
                            </Form.Item>
                              <br/>
                            </Fragment>
                          }

                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{
                              name: `${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '过压值(Mpa)' : '过高(m)'}`,
                              key: 'over'
                            }, {
                              name: `${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '欠压值(Mpa)' : '过低(m)'}`,
                              key: 'under',
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>
                                  {index2 === 2 && <br/>}
                                </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) && Boolean(this.state.hardware_configs.sensor[index].alarm) &&
                            [{
                              name: '报警间隔(秒)',
                              key: 'alarm_upload_interval',
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>

                                </Fragment>;

                            })
                          }


                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'Modbus1'} style={{background: '#fafafa'}}>
                    {
                      [{name: 'Modbus1'}, {name: 'Modbus2'}].map((item, index) => {
                        if (!(this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index].type)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          <Fragment><Form.Item
                            label='设备类型'>

                      <span>
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},
                              {key: 'DOUBLE-VALVE-PLC', name: '双阀PLC'},
                              {key: 'Modbus018', name: '液位探测器Modbus'},
                              {
                                key: 0,
                                name: '无',
                              }], o => o.key === this.state.hardware_configs.modbus_03[index].type) &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},
                              {key: 'DOUBLE-VALVE-PLC', name: '双阀PLC'},
                              {key: 'Modbus018', name: '液位探测器Modbus'},
                              {
                                key: 0,
                                name: '无',
                              }], o => o.key === this.state.hardware_configs.modbus_03[index].type).name}
                        </span>
                          </Form.Item>
                          </Fragment>
                          <br/>
                          {
                            this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '别名', key: 'alias'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >

                            <span>
                              {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                            </span>
                                </Form.Item>

                                <br/>

                              </Fragment>;

                            })
                          }


                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            this.state.hardware_configs.modbus_03[index].type === 'DOUBLE-VALVE-PLC' &&
                            <Fragment>
                              {
                                [{
                                  name: '蝶阀1动作',
                                  key: 'butterfly_valve1_status',
                                }, {
                                  name: '蝶阀2动作',
                                  key: 'butterfly_valve2_status',
                                }, {
                                  name: '蝶阀3动作',
                                  key: 'butterfly_valve3_status',
                                }, {
                                  name: '蝶阀4动作',
                                  key: 'butterfly_valve4_status',
                                }].map((item2, index2) => {
                                  return <Form.Item

                                    key={index2}
                                    label={item2.name}
                                  >
                                    <Select
                                      style={{width: '80px'}}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.modbus_03) {
                                          this.state.hardware_configs.modbus_03 = [];
                                        }
                                        if (this.state.hardware_configs.modbus_03.length < 4) {
                                          if (this.state.hardware_configs.modbus_03[index]) {
                                            this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.modbus_03[index] = {};
                                            this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.modbus_03.splice(index, 1, {
                                            ...this.state.hardware_configs.modbus_03[index],
                                            [item2.key]: e,
                                          });
                                        }
                                        this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                      }}

                                      value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    >
                                      {[{key: 1, name: '开'}, {key: 2, name: '停'}, {
                                        key: 4,
                                        name: '关',
                                      }].map((item, key) => {
                                        return (
                                          <Option key={key}
                                                  value={item.key}>{item.name}</Option>
                                        );
                                      })}
                                    </Select>
                                  </Form.Item>;

                                })

                              }
                            </Fragment>
                          }

                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) && this.state.hardware_configs.modbus_03[index].type === 'Modbus018' &&
                            [{name: '数据上传间隔(秒)', key: 'upload_interval'}, {
                              name: '报警水位(米)',
                              key: 'alarm_water_level'
                            }].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >
                                  <InputNumber
                                    value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    onChange={(e) => {
                                      if (!this.state.hardware_configs.modbus_03) {
                                        this.state.hardware_configs.modbus_03 = [];
                                      }
                                      if (this.state.hardware_configs.modbus_03.length < 2) {
                                        if (this.state.hardware_configs.modbus_03[index]) {
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        } else {
                                          this.state.hardware_configs.modbus_03[index] = {};
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        }
                                      } else {
                                        this.state.hardware_configs.modbus_03.splice(index, 1, {
                                          ...this.state.hardware_configs.modbus_03[index],
                                          [item2.key]: e,
                                        });
                                      }


                                      this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                    }}
                                  />
                                </Form.Item>
                              </Fragment>;

                            })
                          }

                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'数字输入1'} style={{background: '#fafafa'}}>
                    {
                      [{name: '数字输入1'}, {name: '数字输入2'}].map((item, index) => {
                        if (!(this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index].enable)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          <Fragment>

                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].enable) &&
                              [{name: '别名', key: 'alias'}].map((item2, index2) => {
                                return <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >

                              <span>
                                {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                              </span>
                                  </Form.Item>

                                  <br/>

                                </Fragment>;

                              })}

                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) &&
                              [{name: '正常状态数据上传间隔(秒)', key: 'normal_upload_interval'}].map((item2, index2) => {
                                return (this.state.hardware_configs.digital_input[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                  <Fragment key={index2}>
                                    <Form.Item

                                      label={item2.name}
                                    >
                                      <InputNumber
                                        value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                                        onChange={(e) => {
                                          if (!this.state.hardware_configs.digital_input) {
                                            this.state.hardware_configs.digital_input = [];
                                          }
                                          if (this.state.hardware_configs.digital_input.length < 2) {
                                            if (this.state.hardware_configs.digital_input[index]) {
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            } else {
                                              this.state.hardware_configs.digital_input[index] = {};
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            }
                                          } else {
                                            this.state.hardware_configs.digital_input.splice(index, 1, {
                                              ...this.state.hardware_configs.digital_input[index],
                                              [item2.key]: e,
                                            });
                                          }


                                          this.changeConfig({digital_input: this.state.hardware_configs.digital_input});
                                        }}
                                      />
                                    </Form.Item>
                                    <br/>
                                  </Fragment>;

                              })
                            }
                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) &&
                              <Fragment><Form.Item
                                label="是否预警"
                              >
                                <Radio.Group onChange={(e) => {
                                  if (!this.state.hardware_configs.digital_input) {
                                    this.state.hardware_configs.digital_input = [];
                                  }
                                  if (this.state.hardware_configs.digital_input.length < 2) {
                                    if (this.state.hardware_configs.digital_input[index]) {
                                      this.state.hardware_configs.digital_input[index].alarm = e.target.value;
                                    } else {
                                      this.state.hardware_configs.digital_input[index] = {};
                                      this.state.hardware_configs.digital_input[index].alarm = e.target.value;
                                    }
                                  } else {
                                    this.state.hardware_configs.digital_input.splice(index, 1, {
                                      ...this.state.hardware_configs.digital_input[index],
                                      alarm: e.target.value,
                                    });
                                  }
                                  this.changeConfig({digital_input: this.state.hardware_configs.digital_input});
                                }}
                                             value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index].alarm}>
                                  <Radio value={1}>报警</Radio>
                                  <Radio value={0}>不报警</Radio>
                                </Radio.Group>
                              </Form.Item>
                                <br/>
                              </Fragment>
                            }
                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) && Boolean(this.state.hardware_configs.digital_input[index].alarm) &&
                              [{
                                name: '报警状态数据上传间隔(秒)',
                                key: 'alarm_upload_interval',
                              }].map((item2, index2) => {
                                return (this.state.hardware_configs.digital_input[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                  <Fragment key={index2}>
                                    <Form.Item

                                      label={item2.name}
                                    >
                                      <InputNumber
                                        value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                                        onChange={(e) => {
                                          if (!this.state.hardware_configs.digital_input) {
                                            this.state.hardware_configs.digital_input = [];
                                          }
                                          if (this.state.hardware_configs.digital_input.length < 2) {
                                            if (this.state.hardware_configs.digital_input[index]) {
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            } else {
                                              this.state.hardware_configs.digital_input[index] = {};
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            }
                                          } else {
                                            this.state.hardware_configs.digital_input.splice(index, 1, {
                                              ...this.state.hardware_configs.digital_input[index],
                                              [item2.key]: e,
                                            });
                                          }


                                          this.changeConfig({digital_input: this.state.hardware_configs.digital_input});
                                        }}
                                      />
                                    </Form.Item>

                                  </Fragment>;

                              })
                            }


                          </Fragment>


                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
              </Form>
            }

            {
              Number(this.state.templateId) === 14 &&
              <Form layout="inline" style={{paddingBottom: '50px'}}>
                <div className={styles.box_item} style={{paddingTop: '12px'}}>
                  <Tabs size='small' defaultActiveKey={'device'} style={{background: '#fafafa'}}>
                    <TabPane tab={'设备信息'} key={'device'}>

                      <Form.Item
                        label="数据上传间隔(分钟)"
                      >
                        <InputNumber
                          value={this.state.hardware_configs.device && this.state.hardware_configs.device[0].upload_interval}
                          onChange={(e) => {
                            if (!this.state.hardware_configs.device) {
                              this.state.hardware_configs.device = [];
                            }
                            if (this.state.hardware_configs.device.length < 1) {
                              this.state.hardware_configs.device[0] = {};
                              this.state.hardware_configs.device[0].upload_interval = e;
                            } else {
                              this.state.hardware_configs.device.splice(0, 1, {
                                ...this.state.hardware_configs.device[0],
                                upload_interval: e,
                              });
                            }
                            this.changeConfig({device: this.state.hardware_configs.device});
                          }}
                        />
                      </Form.Item>

                    </TabPane>
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'Modbus1'} style={{background: '#fafafa'}}>
                    {
                      [{name: 'Modbus1'}, {name: 'Modbus2'}].map((item, index) => {
                        if (!(this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index].type)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          <Fragment><Form.Item
                            label='设备类型'>

                      <span>
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},
                              {key: 'DOUBLE-VALVE-PLC', name: '双阀PLC'},
                              {key: 'CHEMITEC-50-SERIES', name: '水质检测'},
                              {
                                key: 0,
                                name: '无',
                              }], o => o.key === this.state.hardware_configs.modbus_03[index].type) &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},
                              {key: 'DOUBLE-VALVE-PLC', name: '双阀PLC'},
                              {key: 'CHEMITEC-50-SERIES', name: '水质检测'},
                              {
                                key: 0,
                                name: '无',
                              }], o => o.key === this.state.hardware_configs.modbus_03[index].type).name}
                        </span>
                          </Form.Item>
                          </Fragment>
                          <br/>
                          {/* {
                            this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{ name: '别名', key: 'alias' }].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >

                            <span>
                              {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                            </span>
                                </Form.Item>

                                <br/>

                              </Fragment>;

                            })
                          }*/}


                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            this.state.hardware_configs.modbus_03[index].type === 'CHEMITEC-50-SERIES' &&
                            <Fragment>
                              {
                                [{
                                  name: '通道1接入类型',
                                  key: 'channel1_type',
                                }, {
                                  name: '通道2接入类型',
                                  key: 'channel2_type',
                                }, {
                                  name: '通道3接入类型',
                                  key: 'channel3_type',
                                }, {
                                  name: '通道4接入类型',
                                  key: 'channel4_type',
                                }].map((item2, index2) => {
                                  return <Form.Item

                                    key={index2}
                                    label={item2.name}
                                  >
                                    <Select
                                      style={{width: '80px'}}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.modbus_03) {
                                          this.state.hardware_configs.modbus_03 = [];
                                        }
                                        if (this.state.hardware_configs.modbus_03.length < 4) {
                                          if (this.state.hardware_configs.modbus_03[index]) {
                                            this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.modbus_03[index] = {};
                                            this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.modbus_03.splice(index, 1, {
                                            ...this.state.hardware_configs.modbus_03[index],
                                            [item2.key]: e,
                                          });
                                        }
                                        this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                      }}

                                      value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    >
                                      {[{
                                        key: 0,
                                        name: '禁用',
                                      }, {key: 1, name: 'PH值'}, {key: 2, name: '浊度'}, {
                                        key: 3,
                                        name: '溶氧',
                                      }, {
                                        key: 4,
                                        name: '电导率',
                                      }, {
                                        key: 5,
                                        name: '余氯',
                                      }].map((item, key) => {
                                        return (
                                          <Option key={key}
                                                  value={item.key}>{item.name}</Option>
                                        );
                                      })}
                                    </Select>
                                  </Form.Item>;

                                })

                              }
                            </Fragment>
                          }
                          <br/>
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '数据上传间隔(秒)', key: 'upload_interval'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >
                                  <InputNumber
                                    value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    onChange={(e) => {
                                      if (!this.state.hardware_configs.modbus_03) {
                                        this.state.hardware_configs.modbus_03 = [];
                                      }
                                      if (this.state.hardware_configs.modbus_03.length < 2) {
                                        if (this.state.hardware_configs.modbus_03[index]) {
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        } else {
                                          this.state.hardware_configs.modbus_03[index] = {};
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        }
                                      } else {
                                        this.state.hardware_configs.modbus_03.splice(index, 1, {
                                          ...this.state.hardware_configs.modbus_03[index],
                                          [item2.key]: e,
                                        });
                                      }


                                      this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                    }}
                                  />
                                </Form.Item>
                                <br/>
                              </Fragment>;

                            })
                          }

                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'传感器1'} style={{background: '#fafafa'}}>
                    {
                      [{name: '传感器1'}, {name: '传感器2'}, {name: '传感器3'}, {name: '传感器4'}].map((item, index) => {

                        if (!(this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index].type)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          {
                            this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{name: '别名', key: 'alias'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item
                                  label={item2.name}>

                                <span>
                                 {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                </span>
                                </Form.Item>
                                <br/>
                              </Fragment>;

                            })
                          }


                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{name: '上传间隔(秒)', key: 'normal_upload_interval'}, {
                              name: `波动值(${this.state.hardware_configs.sensor[index].type === 'sensor001' ? 'Mpa' : 'm'})`,
                              key: 'fluctuation_value',
                            }, {
                              name: `满量程${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '(Mpa)' : '(m)'}`,
                              key: 'range_max'
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>

                                  <br/>

                                </Fragment>;

                            })
                          }
                          {/* {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            <Fragment><Form.Item
                              label="是否预警"
                            >
                              <Radio.Group
                                onChange={(e) => {
                                  if (!this.state.hardware_configs.sensor) {
                                    this.state.hardware_configs.sensor = [];
                                  }
                                  if (this.state.hardware_configs.sensor.length < 4) {
                                    if (this.state.hardware_configs.sensor[index]) {
                                      this.state.hardware_configs.sensor[index].alarm = e.target.value;
                                    } else {
                                      this.state.hardware_configs.sensor[index] = {};
                                      this.state.hardware_configs.sensor[index].alarm = e.target.value;
                                    }
                                  } else {
                                    this.state.hardware_configs.sensor.splice(index, 1, {
                                      ...this.state.hardware_configs.sensor[index],
                                      alarm: e.target.value,
                                    });
                                  }
                                  this.changeConfig({ sensor: this.state.hardware_configs.sensor });
                                }}
                                value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index].alarm}>
                                <Radio value={1}>报警</Radio>
                                <Radio value={0}>不报警</Radio>
                              </Radio.Group>
                            </Form.Item>
                              <br/>
                            </Fragment>
                          } */}

                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{
                              name: `${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '过压值(Mpa)' : '过高(m)'}`,
                              key: 'over'
                            }, {
                              name: `${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '欠压值(Mpa)' : '过低(m)'}`,
                              key: 'under',
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>
                                  {index2 === 2 && <br/>}
                                </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) && Boolean(this.state.hardware_configs.sensor[index].alarm) &&
                            [{
                              name: '报警间隔(秒)',
                              key: 'alarm_upload_interval',
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>

                                </Fragment>;

                            })
                          }


                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
              </Form>
            }
            {
              Number(this.state.templateId) === 15 &&
              <Form layout="inline" style={{paddingBottom: '50px'}}>
                <div className={styles.box_item} style={{paddingTop: '12px'}}>
                  <Tabs size='small' defaultActiveKey={'device'} style={{background: '#fafafa'}}>
                    <TabPane tab={'设备信息'} key={'device'}>

                      <Form.Item
                        label="数据上传间隔(分钟)"
                      >
                        <InputNumber
                          value={this.state.hardware_configs.device && this.state.hardware_configs.device[0].upload_interval}
                          onChange={(e) => {
                            if (!this.state.hardware_configs.device) {
                              this.state.hardware_configs.device = [];
                            }
                            if (this.state.hardware_configs.device.length < 1) {
                              this.state.hardware_configs.device[0] = {};
                              this.state.hardware_configs.device[0].upload_interval = e;
                            } else {
                              this.state.hardware_configs.device.splice(0, 1, {
                                ...this.state.hardware_configs.device[0],
                                upload_interval: e,
                              });
                            }
                            this.changeConfig({device: this.state.hardware_configs.device});
                          }}
                        />
                      </Form.Item>

                    </TabPane>
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'Modbus1'} style={{background: '#fafafa'}}>
                    {
                      [{name: 'Modbus1'}].map((item, index) => {
                        if (!(this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index].type)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          <Fragment><Form.Item
                            label='设备类型'>

                      <span>
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},
                              {key: 'DOUBLE-VALVE-PLC', name: '双阀PLC'},
                              {key: 'CHEMITEC-50-SERIES', name: '水质检测'},
                              {key: 'Modbus010', name: '电磁计量器'},
                              {key: 'Modbus011', name: 'Modbus011'},
                              {key: 'Modbus012', name: 'Modbus012'},
                              {key: 'Modbus013', name: 'Modbus013'},
                              {key: 'Modbus019', name: 'Modbus019'},
                              {
                                key: 0,
                                name: '无',
                              }], o => o.key === this.state.hardware_configs.modbus_03[index].type) &&
                            find([{key: 'SCL-61D-LT50', name: '汇中 SCL-61D(管径<50mm)'}, {
                              key: 'SCL-61D-GTE50',
                              name: '汇中 SCL-61D(管径≥50mm)',
                            }, {key: 'PCM380L', name: '压力传感器'}, {key: 'PLC', name: '电动球阀'},
                              {key: 'DOUBLE-VALVE-PLC', name: '双阀PLC'},
                              {key: 'CHEMITEC-50-SERIES', name: '水质检测'},
                              {key: 'Modbus010', name: '电磁计量器'},
                              {key: 'Modbus011', name: 'Modbus011'},
                              {key: 'Modbus012', name: 'Modbus012'},
                              {key: 'Modbus013', name: 'Modbus013'},
                              {key: 'Modbus019', name: 'Modbus019'},
                              {
                                key: 0,
                                name: '无',
                              }], o => o.key === this.state.hardware_configs.modbus_03[index].type).name}
                        </span>
                          </Form.Item>
                          </Fragment>
                          <br/>
                          {
                            this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '别名', key: 'alias'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >

                            <span>
                              {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                            </span>
                                </Form.Item>

                                <br/>

                              </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '数据上传间隔(秒)', key: 'upload_interval'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >
                                  <InputNumber
                                    value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    onChange={(e) => {
                                      if (!this.state.hardware_configs.modbus_03) {
                                        this.state.hardware_configs.modbus_03 = [];
                                      }
                                      if (this.state.hardware_configs.modbus_03.length < 2) {
                                        if (this.state.hardware_configs.modbus_03[index]) {
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        } else {
                                          this.state.hardware_configs.modbus_03[index] = {};
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e;
                                        }
                                      } else {
                                        this.state.hardware_configs.modbus_03.splice(index, 1, {
                                          ...this.state.hardware_configs.modbus_03[index],
                                          [item2.key]: e,
                                        });
                                      }


                                      this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                    }}
                                  />
                                </Form.Item>
                                <br/>
                              </Fragment>;

                            })
                          }

                          {this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && Boolean(this.state.hardware_configs.modbus_03[index].type) &&
                            [{name: '最低瞬时流量报警值', key: 'min_instantaneous_flow'}, {
                              name: '最高瞬时流量报警值',
                              key: 'max_instantaneous_flow'
                            }].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item
                                  help={'填数字或者"-"，值为"-"时关闭报警'}
                                  label={item2.name}
                                  style={{marginBottom: '0'}}
                                >
                                  <Input
                                    value={this.state.hardware_configs.modbus_03 && this.state.hardware_configs.modbus_03[index] && this.state.hardware_configs.modbus_03[index][item2.key]}
                                    onChange={(e) => {
                                      if (!this.state.hardware_configs.modbus_03) {
                                        this.state.hardware_configs.modbus_03 = [];
                                      }
                                      if (this.state.hardware_configs.modbus_03.length < 2) {
                                        if (this.state.hardware_configs.modbus_03[index]) {
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e.target.value;
                                        } else {
                                          this.state.hardware_configs.modbus_03[index] = {};
                                          this.state.hardware_configs.modbus_03[index][item2.key] = e.target.value;
                                        }
                                      } else {
                                        this.state.hardware_configs.modbus_03.splice(index, 1, {
                                          ...this.state.hardware_configs.modbus_03[index],
                                          [item2.key]: e.target.value,
                                        });
                                      }


                                      this.changeConfig({modbus_03: this.state.hardware_configs.modbus_03});
                                    }}
                                  />
                                </Form.Item>
                              </Fragment>;

                            })
                          }

                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
              </Form>
            }
            {
              (Number(this.state.templateId) === 16 || Number(this.state.templateId) === 17 || Number(this.state.templateId) === 18 || Number(this.state.templateId) === 20) &&
              <Form layout="inline" style={{paddingBottom: '50px'}}>
                <div className={styles.box_item} style={{paddingTop: '12px'}}>
                  <Tabs size='small' defaultActiveKey={'device'} style={{background: '#fafafa'}}>
                    <TabPane tab={'设备信息'} key={'device'}>

                      <Form.Item
                        label="数据上传间隔(分钟)"
                      >
                        <InputNumber
                          value={this.state.hardware_configs.device && this.state.hardware_configs.device[0].upload_interval}
                          onChange={(e) => {
                            if (!this.state.hardware_configs.device) {
                              this.state.hardware_configs.device = [];
                            }
                            if (this.state.hardware_configs.device.length < 1) {
                              this.state.hardware_configs.device[0] = {};
                              this.state.hardware_configs.device[0].upload_interval = e;
                            } else {
                              this.state.hardware_configs.device.splice(0, 1, {
                                ...this.state.hardware_configs.device[0],
                                upload_interval: e,
                              });
                            }
                            this.changeConfig({device: this.state.hardware_configs.device});
                          }}
                        />
                      </Form.Item>

                    </TabPane>
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'传感器1'} style={{background: '#fafafa'}}>
                    {
                      [{name: '传感器1'}, {name: '传感器2'}, {name: '传感器3'}, {name: '传感器4'}].map((item, index) => {

                        if (!(this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index].type)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          {
                            this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{name: '别名', key: 'alias'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item
                                  label={item2.name}>

                                <span>
                                 {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                </span>
                                </Form.Item>
                                <br/>
                              </Fragment>;

                            })
                          }


                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{name: '上传间隔(秒)', key: 'normal_upload_interval'}, {
                              name: `波动值(${this.state.hardware_configs.sensor[index].type === 'sensor001' ? 'Mpa' : 'm'})`,
                              key: 'fluctuation_value',
                            }, {
                              name: `满量程${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '(Mpa)' : '(m)'}`,
                              key: 'range_max'
                            }
                            ].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>

                                  <br/>

                                </Fragment>;

                            })
                          }
                         {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            <Fragment><Form.Item
                              label="是否预警"
                            >
                              <Radio.Group
                                onChange={(e) => {
                                  if (!this.state.hardware_configs.sensor) {
                                    this.state.hardware_configs.sensor = [];
                                  }
                                  if (this.state.hardware_configs.sensor.length < 4) {
                                    if (this.state.hardware_configs.sensor[index]) {
                                      this.state.hardware_configs.sensor[index].alarm = e.target.value;
                                    } else {
                                      this.state.hardware_configs.sensor[index] = {};
                                      this.state.hardware_configs.sensor[index].alarm = e.target.value;
                                    }
                                  } else {
                                    this.state.hardware_configs.sensor.splice(index, 1, {
                                      ...this.state.hardware_configs.sensor[index],
                                      alarm: e.target.value,
                                    });
                                  }
                                  this.changeConfig({ sensor: this.state.hardware_configs.sensor });
                                }}
                                value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index].alarm}>
                                <Radio value={1}>报警</Radio>
                                <Radio value={0}>不报警</Radio>
                              </Radio.Group>
                            </Form.Item>
                              <br/>
                            </Fragment>
                          }

                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{
                              name: `${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '过压值(Mpa)' : '过高(m)'}`,
                              key: 'over'
                            }, {
                              name: `${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '欠压值(Mpa)' : '过低(m)'}`,
                              key: 'under',
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>
                                  {index2 === 2 && <br/>}
                                </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) && Boolean(this.state.hardware_configs.sensor[index].alarm) &&
                            [{
                              name: '报警间隔(秒)',
                              key: 'alarm_upload_interval',
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>

                                </Fragment>;

                            })
                          }


                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
              </Form>
            }
            {
              Number(this.state.templateId) === 21 &&
              <Form layout="inline" style={{paddingBottom: '50px'}}>
                <div className={styles.box_item} style={{paddingTop: '12px'}}>
                  <Tabs size='small' defaultActiveKey={'device'} style={{background: '#fafafa'}}>
                    <TabPane tab={'设备信息'} key={'device'}>

                      <Form.Item
                        label="数据上传间隔(分钟)"
                      >
                        <InputNumber
                          value={this.state.hardware_configs.device && this.state.hardware_configs.device[0].upload_interval}
                          onChange={(e) => {
                            if (!this.state.hardware_configs.device) {
                              this.state.hardware_configs.device = [];
                            }
                            if (this.state.hardware_configs.device.length < 1) {
                              this.state.hardware_configs.device[0] = {};
                              this.state.hardware_configs.device[0].upload_interval = e;
                            } else {
                              this.state.hardware_configs.device.splice(0, 1, {
                                ...this.state.hardware_configs.device[0],
                                upload_interval: e,
                              });
                            }
                            this.changeConfig({device: this.state.hardware_configs.device});
                          }}
                        />
                      </Form.Item>
                    </TabPane>
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'传感器1'} style={{background: '#fafafa'}}>
                    {
                      [{name: '传感器1'}, {name: '传感器2'}, {name: '传感器3'}, {name: '传感器4'}].map((item, index) => {

                        if (!(this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index].type)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          {
                            this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{name: '别名', key: 'alias'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item
                                  label={item2.name}>

                                <span>
                                 {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                </span>
                                </Form.Item>
                                <br/>
                              </Fragment>;

                            })
                          }


                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{name: '上传间隔(秒)', key: 'normal_upload_interval'}, {
                              name: `波动值(${this.state.hardware_configs.sensor[index].type === 'sensor001' ? 'Mpa' : 'm'})`,
                              key: 'fluctuation_value',
                            }, {
                              name: `满量程${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '(Mpa)' : '(m)'}`,
                              key: 'range_max'
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>

                                  <br/>

                                </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            <Fragment><Form.Item
                              label="是否预警"
                            >
                              <Radio.Group
                                onChange={(e) => {
                                  if (!this.state.hardware_configs.sensor) {
                                    this.state.hardware_configs.sensor = [];
                                  }
                                  if (this.state.hardware_configs.sensor.length < 4) {
                                    if (this.state.hardware_configs.sensor[index]) {
                                      this.state.hardware_configs.sensor[index].alarm = e.target.value;
                                    } else {
                                      this.state.hardware_configs.sensor[index] = {};
                                      this.state.hardware_configs.sensor[index].alarm = e.target.value;
                                    }
                                  } else {
                                    this.state.hardware_configs.sensor.splice(index, 1, {
                                      ...this.state.hardware_configs.sensor[index],
                                      alarm: e.target.value,
                                    });
                                  }
                                  this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                }}
                                value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index].alarm}>
                                <Radio value={1}>报警</Radio>
                                <Radio value={0}>不报警</Radio>
                              </Radio.Group>
                            </Form.Item>
                              <br/>
                            </Fragment>
                          }

                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{
                              name: `${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '过压值(Mpa)' : '过高(m)'}`,
                              key: 'over'
                            }, {
                              name: `${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '欠压值(Mpa)' : '过低(m)'}`,
                              key: 'under',
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>
                                  {index2 === 2 && <br/>}
                                </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) && Boolean(this.state.hardware_configs.sensor[index].alarm) &&
                            [{
                              name: '报警间隔(秒)',
                              key: 'alarm_upload_interval',
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>

                                </Fragment>;

                            })
                          }


                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'ball_valve1'} style={{background: '#fafafa'}}>
                    {
                      [{name: '球阀1'}, {name: '球阀2'}].map((item, index) => {
                        if (!(this.state.hardware_configs.ball_valve && this.state.hardware_configs.ball_valve[index] && this.state.hardware_configs.ball_valve[index].enable)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          {this.state.hardware_configs.ball_valve && this.state.hardware_configs.ball_valve[index] && Boolean(this.state.hardware_configs.ball_valve[index].enable) &&
                            <Fragment>
                              {
                                [{
                                  name: '过压输出状态',
                                  key: 'parameter2',
                                }, {
                                  name: '正常输出状态',
                                  key: 'parameter3',
                                }, {
                                  name: '欠压输出状态',
                                  key: 'parameter4',
                                }].map((item2, index2) => {
                                  return <Form.Item

                                    key={index2}
                                    label={item2.name}
                                  >
                                    <Select
                                      style={{width: '80px'}}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.ball_valve) {
                                          this.state.hardware_configs.ball_valve = [];
                                        }
                                        if (this.state.hardware_configs.ball_valve.length < 4) {
                                          if (this.state.hardware_configs.ball_valve[index]) {
                                            this.state.hardware_configs.ball_valve[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.ball_valve[index] = {};
                                            this.state.hardware_configs.ball_valve[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.ball_valve.splice(index, 1, {
                                            ...this.state.hardware_configs.ball_valve[index],
                                            [item2.key]: e,
                                          });
                                        }
                                        this.changeConfig({ball_valve: this.state.hardware_configs.ball_valve});
                                      }}

                                      value={this.state.hardware_configs.ball_valve && this.state.hardware_configs.ball_valve[index] && this.state.hardware_configs.ball_valve[index][item2.key]}
                                    >
                                      {[{key: 1, name: '开阀'}, {key: 0, name: '关阀'}].map((item, key) => {
                                        return (
                                          <Option key={key}
                                                  value={item.key}>{item.name}</Option>
                                        );
                                      })}
                                    </Select>
                                  </Form.Item>;

                                })

                              }
                            </Fragment>
                          }
                          {this.state.hardware_configs.ball_valve && this.state.hardware_configs.ball_valve[index] && Boolean(this.state.hardware_configs.ball_valve[index].enable) &&
                            [{name: '正常数据上传间隔(秒)', key: 'normal_upload_interval'}, {
                              name: '报警数据上传间隔(秒)',
                              key: 'alarm_upload_interval'
                            }].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >
                                  <InputNumber
                                    value={this.state.hardware_configs.ball_valve && this.state.hardware_configs.ball_valve[index] && this.state.hardware_configs.ball_valve[index][item2.key]}
                                    onChange={(e) => {
                                      if (!this.state.hardware_configs.ball_valve) {
                                        this.state.hardware_configs.ball_valve = [];
                                      }
                                      if (this.state.hardware_configs.ball_valve.length < 2) {
                                        if (this.state.hardware_configs.ball_valve[index]) {
                                          this.state.hardware_configs.ball_valve[index][item2.key] = e;
                                        } else {
                                          this.state.hardware_configs.ball_valve[index] = {};
                                          this.state.hardware_configs.ball_valve[index][item2.key] = e;
                                        }
                                      } else {
                                        this.state.hardware_configs.ball_valve.splice(index, 1, {
                                          ...this.state.hardware_configs.ball_valve[index],
                                          [item2.key]: e,
                                        });
                                      }


                                      this.changeConfig({ball_valve: this.state.hardware_configs.ball_valve});
                                    }}
                                  />
                                </Form.Item>
                              </Fragment>;

                            })
                          }

                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
              </Form>
            }
            {
              Number(this.state.templateId) === 25 &&
              <Form layout="inline" style={{paddingBottom: '50px'}}>
                <div className={styles.box_item} style={{paddingTop: '12px'}}>
                  <Tabs size='small' defaultActiveKey={'device'} style={{background: '#fafafa'}}>
                    <TabPane tab={'设备信息'} key={'device'}>

                      <Form.Item
                        label="数据上传间隔(分钟)"
                      >
                        <InputNumber
                          value={this.state.hardware_configs.device && this.state.hardware_configs.device[0].upload_interval}
                          onChange={(e) => {
                            if (!this.state.hardware_configs.device) {
                              this.state.hardware_configs.device = [];
                            }
                            if (this.state.hardware_configs.device.length < 1) {
                              this.state.hardware_configs.device[0] = {};
                              this.state.hardware_configs.device[0].upload_interval = e;
                            } else {
                              this.state.hardware_configs.device.splice(0, 1, {
                                ...this.state.hardware_configs.device[0],
                                upload_interval: e,
                              });
                            }
                            this.changeConfig({device: this.state.hardware_configs.device});
                          }}
                        />
                      </Form.Item>
                    </TabPane>
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'传感器1'} style={{background: '#fafafa'}}>
                    {
                      [{name: '传感器1'}, {name: '传感器2'}, {name: '传感器3'}, {name: '传感器4'}].map((item, index) => {

                        if (!(this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index].type)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          {
                            this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{name: '别名', key: 'alias'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item
                                  label={item2.name}>

                                <span>
                                 {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                </span>
                                </Form.Item>
                                <br/>
                              </Fragment>;

                            })
                          }


                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{name: '上传间隔(秒)', key: 'normal_upload_interval'}, {
                              name: `波动值(${this.state.hardware_configs.sensor[index].type === 'sensor001' ? 'Mpa' : 'm'})`,
                              key: 'fluctuation_value',
                            }, {
                              name: `满量程${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '(Mpa)' : '(m)'}`,
                              key: 'range_max'
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>

                                  <br/>

                                </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            <Fragment><Form.Item
                              label="是否预警"
                            >
                              <Radio.Group
                                onChange={(e) => {
                                  if (!this.state.hardware_configs.sensor) {
                                    this.state.hardware_configs.sensor = [];
                                  }
                                  if (this.state.hardware_configs.sensor.length < 4) {
                                    if (this.state.hardware_configs.sensor[index]) {
                                      this.state.hardware_configs.sensor[index].alarm = e.target.value;
                                    } else {
                                      this.state.hardware_configs.sensor[index] = {};
                                      this.state.hardware_configs.sensor[index].alarm = e.target.value;
                                    }
                                  } else {
                                    this.state.hardware_configs.sensor.splice(index, 1, {
                                      ...this.state.hardware_configs.sensor[index],
                                      alarm: e.target.value,
                                    });
                                  }
                                  this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                }}
                                value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index].alarm}>
                                <Radio value={1}>报警</Radio>
                                <Radio value={0}>不报警</Radio>
                              </Radio.Group>
                            </Form.Item>
                              <br/>
                            </Fragment>
                          }

                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{
                              name: `${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '过压值(Mpa)' : '过高(m)'}`,
                              key: 'over'
                            }, {
                              name: `${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '欠压值(Mpa)' : '过低(m)'}`,
                              key: 'under',
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>
                                  {index2 === 2 && <br/>}
                                </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) && Boolean(this.state.hardware_configs.sensor[index].alarm) &&
                            [{
                              name: '报警间隔(秒)',
                              key: 'alarm_upload_interval',
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>

                                </Fragment>;

                            })
                          }


                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'ball_valve1'} style={{background: '#fafafa'}}>
                    {
                      [{name: '球阀1'}, {name: '球阀2'}].map((item, index) => {
                        if (!(this.state.hardware_configs.ball_valve && this.state.hardware_configs.ball_valve[index] && this.state.hardware_configs.ball_valve[index].enable)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          {this.state.hardware_configs.ball_valve && this.state.hardware_configs.ball_valve[index] && Boolean(this.state.hardware_configs.ball_valve[index].enable) &&
                            <Fragment>
                              {
                                [{
                                  name: '过压输出状态',
                                  key: 'parameter2',
                                }, {
                                  name: '正常输出状态',
                                  key: 'parameter3',
                                }, {
                                  name: '欠压输出状态',
                                  key: 'parameter4',
                                }].map((item2, index2) => {
                                  return <Form.Item

                                    key={index2}
                                    label={item2.name}
                                  >
                                    <Select
                                      style={{width: '80px'}}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.ball_valve) {
                                          this.state.hardware_configs.ball_valve = [];
                                        }
                                        if (this.state.hardware_configs.ball_valve.length < 4) {
                                          if (this.state.hardware_configs.ball_valve[index]) {
                                            this.state.hardware_configs.ball_valve[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.ball_valve[index] = {};
                                            this.state.hardware_configs.ball_valve[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.ball_valve.splice(index, 1, {
                                            ...this.state.hardware_configs.ball_valve[index],
                                            [item2.key]: e,
                                          });
                                        }
                                        this.changeConfig({ball_valve: this.state.hardware_configs.ball_valve});
                                      }}

                                      value={this.state.hardware_configs.ball_valve && this.state.hardware_configs.ball_valve[index] && this.state.hardware_configs.ball_valve[index][item2.key]}
                                    >
                                      {[{key: 1, name: '开阀'}, {key: 0, name: '关阀'}].map((item, key) => {
                                        return (
                                          <Option key={key}
                                                  value={item.key}>{item.name}</Option>
                                        );
                                      })}
                                    </Select>
                                  </Form.Item>;

                                })

                              }
                            </Fragment>
                          }
                          {this.state.hardware_configs.ball_valve && this.state.hardware_configs.ball_valve[index] && Boolean(this.state.hardware_configs.ball_valve[index].enable) &&
                            [{name: '正常数据上传间隔(秒)', key: 'normal_upload_interval'}, {
                              name: '报警数据上传间隔(秒)',
                              key: 'alarm_upload_interval'
                            }].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item

                                  label={item2.name}
                                >
                                  <InputNumber
                                    value={this.state.hardware_configs.ball_valve && this.state.hardware_configs.ball_valve[index] && this.state.hardware_configs.ball_valve[index][item2.key]}
                                    onChange={(e) => {
                                      if (!this.state.hardware_configs.ball_valve) {
                                        this.state.hardware_configs.ball_valve = [];
                                      }
                                      if (this.state.hardware_configs.ball_valve.length < 2) {
                                        if (this.state.hardware_configs.ball_valve[index]) {
                                          this.state.hardware_configs.ball_valve[index][item2.key] = e;
                                        } else {
                                          this.state.hardware_configs.ball_valve[index] = {};
                                          this.state.hardware_configs.ball_valve[index][item2.key] = e;
                                        }
                                      } else {
                                        this.state.hardware_configs.ball_valve.splice(index, 1, {
                                          ...this.state.hardware_configs.ball_valve[index],
                                          [item2.key]: e,
                                        });
                                      }


                                      this.changeConfig({ball_valve: this.state.hardware_configs.ball_valve});
                                    }}
                                  />
                                </Form.Item>
                              </Fragment>;

                            })
                          }

                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'数字输入1'} style={{background: '#fafafa'}}>
                    {
                      !(this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[0] && this.state.hardware_configs.digital_input[0].enable) &&
                      <Button type={'primary'} onClick={()=>{
                        this.state.hardware_configs.digital_input[0].enable = 1;
                        this.state.hardware_configs.digital_input[0].alias = '井盖传感器';
                        this.state.hardware_configs.digital_input[0].type = 'DigitalInput003';
                        this.state.hardware_configs.digital_input[0].alarm = 1;
                        this.state.hardware_configs.digital_input[0].normal_upload_interval = 600;
                        this.state.hardware_configs.digital_input[0].alarm_upload_interval = 30;
                        this.setState({
                          hardware_configs:this.state.hardware_configs
                        })
                      }}>添加井盖</Button>

                    }
                    {
                      [{name: '数字输入1'}, {name: '数字输入2'}].map((item, index) => {
                        if (!(this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index].enable)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          <Fragment>

                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].enable) &&
                              [{name: '别名', key: 'alias'}].map((item2, index2) => {
                                return <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >

                              <span>
                                {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                              </span>
                                  </Form.Item>

                                  <br/>

                                </Fragment>;

                              })}

                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) &&
                              [{name: '正常状态数据上传间隔(秒)', key: 'normal_upload_interval'}].map((item2, index2) => {
                                return (this.state.hardware_configs.digital_input[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                  <Fragment key={index2}>
                                    <Form.Item

                                      label={item2.name}
                                    >
                                      <InputNumber
                                        value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                                        onChange={(e) => {
                                          if (!this.state.hardware_configs.digital_input) {
                                            this.state.hardware_configs.digital_input = [];
                                          }
                                          if (this.state.hardware_configs.digital_input.length < 2) {
                                            if (this.state.hardware_configs.digital_input[index]) {
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            } else {
                                              this.state.hardware_configs.digital_input[index] = {};
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            }
                                          } else {
                                            this.state.hardware_configs.digital_input.splice(index, 1, {
                                              ...this.state.hardware_configs.digital_input[index],
                                              [item2.key]: e,
                                            });
                                          }


                                          this.changeConfig({digital_input: this.state.hardware_configs.digital_input});
                                        }}
                                      />
                                    </Form.Item>
                                    <br/>
                                  </Fragment>;

                              })
                            }
                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) &&
                              <Fragment><Form.Item
                                label="是否预警"
                              >
                                <Radio.Group onChange={(e) => {
                                  if (!this.state.hardware_configs.digital_input) {
                                    this.state.hardware_configs.digital_input = [];
                                  }
                                  if (this.state.hardware_configs.digital_input.length < 2) {
                                    if (this.state.hardware_configs.digital_input[index]) {
                                      this.state.hardware_configs.digital_input[index].alarm = e.target.value;
                                    } else {
                                      this.state.hardware_configs.digital_input[index] = {};
                                      this.state.hardware_configs.digital_input[index].alarm = e.target.value;
                                    }
                                  } else {
                                    this.state.hardware_configs.digital_input.splice(index, 1, {
                                      ...this.state.hardware_configs.digital_input[index],
                                      alarm: e.target.value,
                                    });
                                  }
                                  this.changeConfig({digital_input: this.state.hardware_configs.digital_input});
                                }}
                                             value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index].alarm}>
                                  <Radio value={1}>报警</Radio>
                                  <Radio value={0}>不报警</Radio>
                                </Radio.Group>
                              </Form.Item>
                                <br/>
                              </Fragment>
                            }
                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) && Boolean(this.state.hardware_configs.digital_input[index].alarm) &&
                              [{
                                name: '报警状态数据上传间隔(秒)',
                                key: 'alarm_upload_interval',
                              }].map((item2, index2) => {
                                return (this.state.hardware_configs.digital_input[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                  <Fragment key={index2}>
                                    <Form.Item

                                      label={item2.name}
                                    >
                                      <InputNumber
                                        value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                                        onChange={(e) => {
                                          if (!this.state.hardware_configs.digital_input) {
                                            this.state.hardware_configs.digital_input = [];
                                          }
                                          if (this.state.hardware_configs.digital_input.length < 2) {
                                            if (this.state.hardware_configs.digital_input[index]) {
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            } else {
                                              this.state.hardware_configs.digital_input[index] = {};
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            }
                                          } else {
                                            this.state.hardware_configs.digital_input.splice(index, 1, {
                                              ...this.state.hardware_configs.digital_input[index],
                                              [item2.key]: e,
                                            });
                                          }


                                          this.changeConfig({digital_input: this.state.hardware_configs.digital_input});
                                        }}
                                      />
                                    </Form.Item>

                                  </Fragment>;

                              })
                            }


                          </Fragment>


                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
              </Form>
            }
            {
              Number(this.state.templateId) === 27 &&
              <Form layout="inline" style={{paddingBottom: '50px'}}>
                <div className={styles.box_item} style={{paddingTop: '12px'}}>
                  <Tabs size='small' defaultActiveKey={'device'} style={{background: '#fafafa'}}>
                    <TabPane tab={'设备信息'} key={'device'}>

                      <Form.Item
                        label="数据上传间隔(分钟)"
                      >
                        <InputNumber
                          value={this.state.hardware_configs.device && this.state.hardware_configs.device[0].upload_interval}
                          onChange={(e) => {
                            if (!this.state.hardware_configs.device) {
                              this.state.hardware_configs.device = [];
                            }
                            if (this.state.hardware_configs.device.length < 1) {
                              this.state.hardware_configs.device[0] = {};
                              this.state.hardware_configs.device[0].upload_interval = e;
                            } else {
                              this.state.hardware_configs.device.splice(0, 1, {
                                ...this.state.hardware_configs.device[0],
                                upload_interval: e,
                              });
                            }
                            this.changeConfig({device: this.state.hardware_configs.device});
                          }}
                        />
                      </Form.Item>
                    </TabPane>
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'传感器1'} style={{background: '#fafafa'}}>
                    {
                      [{name: '传感器1'}, {name: '传感器2'}, {name: '传感器3'}, {name: '传感器4'}].map((item, index) => {

                        if (!(this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index].type)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          {
                            this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{name: '别名', key: 'alias'}].map((item2, index2) => {
                              return <Fragment key={index2}>
                                <Form.Item
                                  label={item2.name}>

                                <span>
                                 {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                </span>
                                </Form.Item>
                                <br/>
                              </Fragment>;

                            })
                          }


                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{name: '上传间隔(秒)', key: 'normal_upload_interval'}, {
                              name: `波动值(${this.state.hardware_configs.sensor[index].type === 'sensor001' ? 'Mpa' : 'm'})`,
                              key: 'fluctuation_value',
                            }, {
                              name: `满量程${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '(Mpa)' : '(m)'}`,
                              key: 'range_max'
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>

                                  <br/>

                                </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            <Fragment><Form.Item
                              label="是否预警"
                            >
                              <Radio.Group
                                onChange={(e) => {
                                  if (!this.state.hardware_configs.sensor) {
                                    this.state.hardware_configs.sensor = [];
                                  }
                                  if (this.state.hardware_configs.sensor.length < 4) {
                                    if (this.state.hardware_configs.sensor[index]) {
                                      this.state.hardware_configs.sensor[index].alarm = e.target.value;
                                    } else {
                                      this.state.hardware_configs.sensor[index] = {};
                                      this.state.hardware_configs.sensor[index].alarm = e.target.value;
                                    }
                                  } else {
                                    this.state.hardware_configs.sensor.splice(index, 1, {
                                      ...this.state.hardware_configs.sensor[index],
                                      alarm: e.target.value,
                                    });
                                  }
                                  this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                }}
                                value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index].alarm}>
                                <Radio value={1}>报警</Radio>
                                <Radio value={0}>不报警</Radio>
                              </Radio.Group>
                            </Form.Item>
                              <br/>
                            </Fragment>
                          }

                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) &&
                            [{
                              name: `${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '过压值(Mpa)' : '过高(m)'}`,
                              key: 'over'
                            }, {
                              name: `${this.state.hardware_configs.sensor[index].type === 'sensor001' ? '欠压值(Mpa)' : '过低(m)'}`,
                              key: 'under',
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>
                                  {index2 === 2 && <br/>}
                                </Fragment>;

                            })
                          }
                          {this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && Boolean(this.state.hardware_configs.sensor[index].type) && Boolean(this.state.hardware_configs.sensor[index].alarm) &&
                            [{
                              name: '报警间隔(秒)',
                              key: 'alarm_upload_interval',
                            }].map((item2, index2) => {
                              return (this.state.hardware_configs.sensor[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >
                                    <InputNumber
                                      value={this.state.hardware_configs.sensor && this.state.hardware_configs.sensor[index] && this.state.hardware_configs.sensor[index][item2.key]}
                                      onChange={(e) => {
                                        if (!this.state.hardware_configs.sensor) {
                                          this.state.hardware_configs.sensor = [];
                                        }
                                        if (this.state.hardware_configs.sensor.length < 4) {
                                          if (this.state.hardware_configs.sensor[index]) {
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          } else {
                                            this.state.hardware_configs.sensor[index] = {};
                                            this.state.hardware_configs.sensor[index][item2.key] = e;
                                          }
                                        } else {
                                          this.state.hardware_configs.sensor.splice(index, 1, {
                                            ...this.state.hardware_configs.sensor[index],
                                            [item2.key]: e,
                                          });
                                        }


                                        this.changeConfig({sensor: this.state.hardware_configs.sensor});
                                      }}
                                    />
                                  </Form.Item>

                                </Fragment>;

                            })
                          }


                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
                <div className={styles.box_item}>
                  <Tabs size='small' defaultActiveKey={'数字输入1'} style={{background: '#fafafa'}}>
                  {/*  {
                      !(this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[0] && this.state.hardware_configs.digital_input[0].enable) &&
                      <Button type={'primary'} onClick={()=>{
                        this.state.hardware_configs.digital_input[0].enable = 1;
                        this.state.hardware_configs.digital_input[0].alias = '井盖传感器';
                        this.state.hardware_configs.digital_input[0].type = 'DigitalInput003';
                        this.state.hardware_configs.digital_input[0].alarm = 1;
                        this.state.hardware_configs.digital_input[0].normal_upload_interval = 600;
                        this.state.hardware_configs.digital_input[0].alarm_upload_interval = 30;
                        this.setState({
                          hardware_configs:this.state.hardware_configs
                        })
                      }}>添加井盖</Button>

                    }*/}
                    {
                      [{name: '数字输入1'}, {name: '数字输入2'}].map((item, index) => {
                        if (!(this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index].enable)) {
                          return false;
                        }
                        return <TabPane tab={item.name} key={item.name}>
                          <Fragment>

                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].enable) &&
                              [{name: '别名', key: 'alias'}].map((item2, index2) => {
                                return <Fragment key={index2}>
                                  <Form.Item

                                    label={item2.name}
                                  >

                              <span>
                                {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                              </span>
                                  </Form.Item>

                                  <br/>

                                </Fragment>;

                              })}

                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) &&
                              [{name: '正常状态数据上传间隔(秒)', key: 'normal_upload_interval'}].map((item2, index2) => {
                                return (this.state.hardware_configs.digital_input[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                  <Fragment key={index2}>
                                    <Form.Item

                                      label={item2.name}
                                    >
                                      <InputNumber
                                        value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                                        onChange={(e) => {
                                          if (!this.state.hardware_configs.digital_input) {
                                            this.state.hardware_configs.digital_input = [];
                                          }
                                          if (this.state.hardware_configs.digital_input.length < 2) {
                                            if (this.state.hardware_configs.digital_input[index]) {
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            } else {
                                              this.state.hardware_configs.digital_input[index] = {};
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            }
                                          } else {
                                            this.state.hardware_configs.digital_input.splice(index, 1, {
                                              ...this.state.hardware_configs.digital_input[index],
                                              [item2.key]: e,
                                            });
                                          }


                                          this.changeConfig({digital_input: this.state.hardware_configs.digital_input});
                                        }}
                                      />
                                    </Form.Item>
                                    <br/>
                                  </Fragment>;

                              })
                            }
                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) &&
                              <Fragment><Form.Item
                                label="是否预警"
                              >
                                <Radio.Group onChange={(e) => {
                                  if (!this.state.hardware_configs.digital_input) {
                                    this.state.hardware_configs.digital_input = [];
                                  }
                                  if (this.state.hardware_configs.digital_input.length < 2) {
                                    if (this.state.hardware_configs.digital_input[index]) {
                                      this.state.hardware_configs.digital_input[index].alarm = e.target.value;
                                    } else {
                                      this.state.hardware_configs.digital_input[index] = {};
                                      this.state.hardware_configs.digital_input[index].alarm = e.target.value;
                                    }
                                  } else {
                                    this.state.hardware_configs.digital_input.splice(index, 1, {
                                      ...this.state.hardware_configs.digital_input[index],
                                      alarm: e.target.value,
                                      mode: e.target.value===1?2:1,
                                    });
                                  }
                                  this.changeConfig({digital_input: this.state.hardware_configs.digital_input});
                                }}
                                             value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index].alarm}>
                                  <Radio value={1}>报警</Radio>
                                  <Radio value={0}>不报警</Radio>
                                </Radio.Group>
                              </Form.Item>
                                <br/>
                              </Fragment>
                            }
                            {this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && Boolean(this.state.hardware_configs.digital_input[index].type) && Boolean(this.state.hardware_configs.digital_input[index].alarm) &&
                              [{
                                name: '报警状态数据上传间隔(秒)',
                                key: 'alarm_upload_interval',
                              }].map((item2, index2) => {
                                return (this.state.hardware_configs.digital_input[index].alarm === 1 || item2.key.indexOf('cancel') === -1) &&
                                  <Fragment key={index2}>
                                    <Form.Item

                                      label={item2.name}
                                    >
                                      <InputNumber
                                        value={this.state.hardware_configs.digital_input && this.state.hardware_configs.digital_input[index] && this.state.hardware_configs.digital_input[index][item2.key]}
                                        onChange={(e) => {
                                          if (!this.state.hardware_configs.digital_input) {
                                            this.state.hardware_configs.digital_input = [];
                                          }
                                          if (this.state.hardware_configs.digital_input.length < 2) {
                                            if (this.state.hardware_configs.digital_input[index]) {
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            } else {
                                              this.state.hardware_configs.digital_input[index] = {};
                                              this.state.hardware_configs.digital_input[index][item2.key] = e;
                                            }
                                          } else {
                                            this.state.hardware_configs.digital_input.splice(index, 1, {
                                              ...this.state.hardware_configs.digital_input[index],
                                              [item2.key]: e,
                                            });
                                          }


                                          this.changeConfig({digital_input: this.state.hardware_configs.digital_input});
                                        }}
                                      />
                                    </Form.Item>

                                  </Fragment>;

                              })
                            }


                          </Fragment>


                        </TabPane>;
                      })
                    }
                  </Tabs>
                </div>
              </Form>
            }
            {
              Number(this.state.templateId) === 40 &&
              <Form layout="inline" style={{paddingBottom: '50px'}}>
                <div className={styles.box_item} style={{background:'rgb(250, 250, 250)',padding:'10px 40px'}}>
                    {this.state.hardware_configs.protobuf_json && this.state.hardware_configs.protobuf_json.rtu03&&
                    [{name: "传感器类型", key: 'type'}].map((item2, index2) => {
                      return <Fragment key={index2}>
                        <Form.Item

                          label={item2.name}
                        >
                          <Select
                            value={this.state.hardware_configs.protobuf_json && this.state.hardware_configs.protobuf_json.rtu03 && this.state.hardware_configs.protobuf_json.rtu03.sensor_cfg[item2.key]}
                            onChange={(e) => {
                              if (!this.state.hardware_configs.protobuf_json.rtu03.sensor_cfg) {
                                this.state.hardware_configs.protobuf_json.rtu03.sensor_cfg = {};
                              }
                              this.state.hardware_configs.protobuf_json.rtu03.sensor_cfg={
                                ... this.state.hardware_configs.protobuf_json.rtu03.sensor_cfg,
                                [item2.key]: e,
                              };


                              this.changeConfig({protobuf_json: this.state.hardware_configs.protobuf_json});
                            }}
                          >
                            <Option value={'CURRENT'}>电流类型</Option>
                            <Option value={'VOLTAGE'}>电压类型</Option>
                          </Select>
                        </Form.Item>
                        <br/>
                      </Fragment>;

                    })
                    }
                  {this.state.hardware_configs.protobuf_json && this.state.hardware_configs.protobuf_json.rtu03&&
                    [{name: '量程(MPa)', key: 'range'}, {
                      name: '波动值(MPa)',
                      key: 'wave'
                    }].map((item2, index2) => {
                      return <Fragment key={index2}>
                        <Form.Item

                          label={item2.name}
                        >
                          <InputNumber
                            value={this.state.hardware_configs.protobuf_json && this.state.hardware_configs.protobuf_json.rtu03 && this.state.hardware_configs.protobuf_json.rtu03.sensor_cfg[item2.key]}
                            onChange={(e) => {
                              if (!this.state.hardware_configs.protobuf_json.rtu03.sensor_cfg) {
                                this.state.hardware_configs.protobuf_json.rtu03.sensor_cfg = {};
                              }
                              this.state.hardware_configs.protobuf_json.rtu03.sensor_cfg={
                                ... this.state.hardware_configs.protobuf_json.rtu03.sensor_cfg,
                                [item2.key]: e,
                              };


                              this.changeConfig({protobuf_json: this.state.hardware_configs.protobuf_json});
                            }}
                          />
                        </Form.Item>
                        <br/>
                      </Fragment>;

                    })
                  }
                  {this.state.hardware_configs.protobuf_json && this.state.hardware_configs.protobuf_json.rtu03&&
                    [{name: '设备状态上传间隔(秒)', key: 'state_interval'}, {
                      name: '数据采集上传间隔(秒)',
                      key: 'record_interval'
                    }].map((item2, index2) => {
                      return <Fragment key={index2}>
                        <Form.Item

                          label={item2.name}
                        >
                          <InputNumber
                            value={this.state.hardware_configs.protobuf_json && this.state.hardware_configs.protobuf_json.rtu03 &&
                              this.state.hardware_configs.protobuf_json.rtu03.device_cfg[item2.key]}
                            onChange={(e) => {
                              if (!this.state.hardware_configs.protobuf_json.rtu03.device_cfg) {
                                this.state.hardware_configs.protobuf_json.rtu03.device_cfg = {};
                              }
                              this.state.hardware_configs.protobuf_json.rtu03.device_cfg={
                                ... this.state.hardware_configs.protobuf_json.rtu03.device_cfg,
                                [item2.key]: e,
                              };


                              this.changeConfig({protobuf_json: this.state.hardware_configs.protobuf_json});
                            }}
                          />
                        </Form.Item>
                        <br/>
                      </Fragment>;

                    })
                  }
                  {this.state.hardware_configs.protobuf_json && this.state.hardware_configs.protobuf_json.rtu03&&
                    [{name: '泄压微电机控制延时(秒)', key: 'delay'}].map((item2, index2) => {
                      return <Fragment key={index2}>
                        <Form.Item

                          label={item2.name}
                        >
                          <InputNumber
                            value={this.state.hardware_configs.protobuf_json && this.state.hardware_configs.protobuf_json.rtu03 &&
                              this.state.hardware_configs.protobuf_json.rtu03.micro_motor_cfg[item2.key]}
                            onChange={(e) => {
                              if (!this.state.hardware_configs.protobuf_json.rtu03.micro_motor_cfg) {
                                this.state.hardware_configs.protobuf_json.rtu03.micro_motor_cfg = {};
                              }
                              this.state.hardware_configs.protobuf_json.rtu03.micro_motor_cfg={
                                ... this.state.hardware_configs.protobuf_json.rtu03.micro_motor_cfg,
                                [item2.key]: e,
                              };


                              this.changeConfig({protobuf_json: this.state.hardware_configs.protobuf_json});
                            }}
                          />
                        </Form.Item>
                        <br/>
                      </Fragment>;

                    })
                  }
                  {this.state.hardware_configs.protobuf_json && this.state.hardware_configs.protobuf_json.rtu03&& this.state.hardware_configs.protobuf_json.rtu03.valve_cfg
                    && this.state.hardware_configs.protobuf_json.rtu03.valve_cfg.method_m1_param&&
                    [{name: 'P0', key: 'p0'},{name: 'P1', key: 'p1'},{name: 'P2', key: 'p2'},{name: 'P3', key: 'p3'}].map((item2, index2) => {
                      return <Fragment key={index2}>
                        <Form.Item

                          label={item2.name}
                        >
                          <InputNumber
                            value={this.state.hardware_configs.protobuf_json && this.state.hardware_configs.protobuf_json.rtu03 &&this.state.hardware_configs.protobuf_json.rtu03.valve_cfg &&
                              this.state.hardware_configs.protobuf_json.rtu03.valve_cfg.method_m1_param[item2.key]}
                            onChange={(e) => {
                              if (!this.state.hardware_configs.protobuf_json.rtu03.valve_cfg.method_m1_param) {
                                this.state.hardware_configs.protobuf_json.rtu03.valve_cfg.method_m1_param = {};
                              }
                              this.state.hardware_configs.protobuf_json.rtu03.valve_cfg.method_m1_param={
                                ... this.state.hardware_configs.protobuf_json.rtu03.valve_cfg.method_m1_param,
                                [item2.key]: e,
                              };


                              this.changeConfig({protobuf_json: this.state.hardware_configs.protobuf_json});
                            }}
                          />
                        </Form.Item>
                        <br/>
                      </Fragment>;

                    })
                  }
                </div>
              </Form>
            }
          </Fragment>}

        <div
          style={{
            position: 'absolute',
            right: 0,
            bottom: 0,
            width: '100%',
            borderTop: '1px solid #e9e9e9',
            padding: '10px 16px',
            background: '#fff',
            textAlign: 'right',
          }}
        >
          <Button onClick={this.props.onClose} style={{marginRight: 8}}>
            取消
          </Button>
          <Button onClick={() => {
            if (this.state.point.length === 0 && !this.props.fromPipeHome) {
              message.error('请在地图上选择一个点');
              return;
            }
            if (!Boolean(Number(this.state.templateId))) {
              message.error('请选择站点类型');
              return;
            }
            console.log(this.state.templateId);
            console.log('this.state', this.state.hardware_configs);
            this.props.onSave(this.state.templateId, this.state.hardware_configs);
          }} type="primary">
            确定
          </Button>
        </div>
        <Modal
          title={<BuildModalTitle visible={this.state.configModal} modalClass="configModal"
                                  title={`${this.state.device_number} 调节阀配置`}/>}
          destroyOnClose
          onCancel={() => {
            this.setState({
              configModal: false,
              editRecord: {},
            });
          }}
          centered
          className="configModal"
          afterClose={() => {
            afterCloseModal(); // destroyOnClose需要
          }}
          visible={this.state.configModal}
          onOk={this.handleEditConfig}

          footer={[
            <Button key="back" onClick={() => {
              this.setState({
                configModal: false,
                editRecord: {},
              });
            }}>
              取消
            </Button>,
            <Button key="submit" type="primary" loading={this.state.loading} onClick={this.handleEditConfig}>
              确定
            </Button>,
          ]}

        >
          <ControlValveConfig
            wrappedComponentRef={(inst) => this.ConfigForm = inst}
            hardware_configs={this.state.hardware_configs} config_index={this.state.config_index}/>
        </Modal>
      </div>
    );
  }
}

const AddPoliciesFormWrap = Form.create()(AddPoliciesForm);
export default connect()(AddPoliciesFormWrap);
